description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a, b, c, d = [int(x) for x in input().split()] n = a + b + c + d if a > b + 1 or d > c + 1: print("NO") elif a == b + 1: if c > 0 or d > 0: print("NO") else: ls = [0, 1] * b + [0] print("YES") print(*ls) elif d == c + 1: if a > 0 or b > 0: print("NO") else: ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP LIST NUMBER NUMBER VAR LIST N...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
def find_ans(a, b, c, d): if a == 0 and b == 0: if d == c + 1: str_ = "2 3 " * c str_ = "3 " + str_ print("YES") print(str_) return elif d == 0 and c == 0: if a - 1 == b: str_ = "0 1 " * b str_ = str_ + "0" ...
FUNC_DEF IF VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR RETURN IF VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CAL...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
def printres(res): print("YES") print(" ".join(map(str, res))) def main(): cc = [int(a) for a in input().split()] nz = [] for i, c in enumerate(cc): if c > 0: nz.append(i) if len(nz) == 1: if cc[nz[0]] == 1: printres([nz[0]]) else: pr...
FUNC_DEF EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER IF VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR LIST V...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
def main(): freq = [int(s) for s in input().split()] for first in range(4): f = [_ for _ in freq] if f[first] == 0: continue res = [first] f[first] -= 1 while True: add = 0 while add < 4 and (f[add] == 0 or res[-1] - add not in {-1, 1})...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR LIST VAR VAR VAR NUMBER WHILE NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER NUMBER VAR NUMBER IF VAR NUMBER IF FUNC_CALL VAR VAR NUMB...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
import sys readline = sys.stdin.readline readlines = sys.stdin.readlines ns = lambda: readline().rstrip() ni = lambda: int(readline().rstrip()) nm = lambda: map(int, readline().split()) nl = lambda: list(map(int, readline().split())) prn = lambda x: print(*x, sep="\n") def solve(): g = nl() n = sum(g) fo...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN 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 STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VA...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
n0, n1, n2, n3 = map(int, input().split()) num = [] if n0 - n1 >= 2 or n3 - n2 >= 2: print("NO") exit(0) t1 = n1 - n0 t2 = n2 - n3 if t1 == -1: if n2 == 0 and n3 == 0: print("YES") for i in range(n1): print("0 1", end=" ") print(0) exit(0) else: print(...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR V...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
from sys import stdin def rl(): return [int(w) for w in stdin.readline().split()] a, b, c, d = rl() class Fail(Exception): pass def go(x): s = [a, b, c, d] r = [] while sum(s) > 0: r.append(x) s[x] -= 1 if s[x] < 0: return if x == 0: x ...
FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR CLASS_DEF VAR FUNC_DEF ASSIGN VAR LIST VAR VAR VAR VAR ASSIGN VAR LIST WHILE FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR VAR NUMBER RETURN IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUM...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a, b, c, d = [int(x) for x in input().split(" ")] if abs(a + c - b - d) > 1: print("NO") elif d > c: if d - c > 1: print("NO") elif a != 0 or b != 0: print("NO") else: print("YES") for i in range(c): print(3, 2, sep=" ", end=" ") print(3) elif a > b: ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL ...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
def solve(a, e): if not a[e]: return False, [] a = list(a[:]) ans = [e] a[e] -= 1 for i in range(sum(a)): if ans[-1] - 1 >= 0 and a[ans[-1] - 1] > 0: v = ans[-1] - 1 ans.append(v) a[v] -= 1 elif ans[-1] + 1 <= 3 and a[ans[-1] + 1] > 0: ...
FUNC_DEF IF VAR VAR RETURN NUMBER LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER NUMB...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
import sys reader = (map(int, line.split()) for line in sys.stdin) input = reader.__next__ def beatSeq(a, b, c, d): left = [] while a > 0 and b > 0: left.append(0) left.append(1) a -= 1 b -= 1 if a > 1: return None elif a == 1: if c + d > 0: ...
IMPORT ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_DEF ASSIGN VAR LIST WHILE VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN NONE IF VAR NUMBER IF BIN_OP VAR VAR NUMBER RETURN NONE EXPR FUNC_CALL VAR NUMBER RETURN VAR ASSIGN...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
import sys def weave(a, b, na, nb): aNext = True arr = [] while True: if aNext: if a == 0: break arr.append(na) a -= 1 else: if b == 0: break arr.append(nb) b -= 1 aNext = not aN...
IMPORT FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE NUMBER IF VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER NUM...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
import sys ip = lambda: sys.stdin.readline().rstrip() a, b, c, d = map(int, ip().split()) ans = [-1] * (a + b + c + d) if a - b > 1 or d - c > 1: print("NO") elif a - b == 1: if c or d: print("NO") else: print("YES") print("0 1 " * b, end="") print("0") elif d - c == 1: ...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_C...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a, b, c, d = map(int, input().split()) arr = [] for i in range(c): arr.append(-1) arr.append(2) for i in range(a): arr.append(-1) arr.append(0) arr.append(-1) la = len(arr) i = 0 while d > 0 and i < la: if arr[i] == -1: if i > 0 and i != la - 1 and arr[i - 1] == 2 and arr[i + 1] == 2: ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR ...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a, b, c, d = map(int, input().split()) if a == b and b == 0: if abs(c - d) > 1: print("NO") else: print("YES") if c > d: for i in range(d): print("2 3", end=" ") print("2") elif d > c: for i in range(c): print("3...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR STRING IF VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a, b, c, d = list(map(int, input().split())) b -= a c -= d arr = [] k = True if b >= 0 and c >= 0: if a == 0 and b == 0 and c == 1: print("YES") arr.append(2) for i in range(d): arr.append(3) arr.append(2) print(*arr, sep=" ") k = False elif d == 0...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a, b, c, d = map(int, input().split()) if abs(a + c - b - d) <= 1 and b >= a and c >= d: print("YES") if a + c > b + d: for i in range(a): print(0, 1, end=" ") for i in range(b - a): print(2, 1, end=" ") for i in range(d): print(2, 3, end=" ") ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR NUMBER VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING IF BIN_OP VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER STRING FOR VAR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL V...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
g = list(map(int, input().split())) v = [-1, 1, 0, 0, 1, -1] g.insert(0, 0) g.append(0) for i in range(1, 5, 1): if g[i] == 0: continue s = [i] c = g.copy() c[i] -= 1 while c[1] + c[2] + c[3] + c[4] > 0: a = s[-1] - 1 b = s[-1] + 1 if v[b] > v[a]: a, b = b...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VAR VAR NUMBER ASSIGN VAR LIST VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER WHILE BIN_OP BI...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a, b, c, d = map(int, input().split()) n = a + b + c + d if n == 1 and a == 1: print("YES") print(0) elif n == 2 and b == 2: print("NO") elif a == 0 and b == 0: if c == 0: if d == 1: print("YES") print(3) else: print("NO") elif d == c - 1 or d == c...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING ...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
def main(): A, B, C, D = map(int, input().split()) N = A + B + C + D ans = [0] * N a, b, c, d = A - 1, B, C, D prev = 0 ok = 1 for i in range(1, N): if a < 0 or b < 0 or c < 0 or d < 0: ok = 0 break if prev == 0: b -= 1 ans[i] =...
FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NU...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
import sys def main(): a, b, c, d = get_ints() if a + b + c + d == 1: print("YES") if a == 1: print(0) return if b == 1: print(1) return if c == 1: print(2) return if d == 1: print(3) ...
IMPORT FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR IF BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN FUNC_D...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
import sys input = sys.stdin.readline a, b, c, d = map(int, input().split()) res = 0 str1 = [] str2 = [] str3 = [] if a > 0: str1.append("0 ") a -= 1 if d > 0: str2.append("3 ") d = d - 1 res = 0 while a > 0: if b > 0: str1.append("1 0 ") a -= 1 b -= 1 else: res ...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST IF VAR NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR NUMBE...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a, b, c, d = [int(x) for x in input().split()] dn = {(0): a, (1): b, (2): c, (3): d} total = a + b + c + d flag = 1 for i in range(4): if dn[i] == 0: continue soln = [] soln.append(i) td = dn.copy() td[i] -= 1 last = i for j in range(total - 1): if td.get(last - 1, 0): ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a = list(map(int, input().split())) s = a[0] + a[1] + a[2] + a[3] out = [] if s == 1: for i in range(4): if a[i] > 0: print("YES") print(i) return for i in range(3): fst, snd = i, i + 1 if a[fst] == a[snd]: check = True for j in range(4): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR LIST IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR RETURN FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
def make(num, a, b): arr = [(a if i % 2 == 0 else b) for i in range(2 * num)] return arr def is_valid(a, n): for i in range(1, n): if abs(a[i] - a[i - 1]) != 1: return False return True def solve(a): ans = [] n = len(a) flg = True for i in range(n - 1): if...
FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER NUMBER VAR VAR VAR FUNC_CALL VAR BIN_OP NUMBER VAR RETURN VAR FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER VAR IF FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a, b, c, d = [int(x) for x in input().split()] if b >= a and c >= d: b2 = b - a c2 = c - d if abs(c2 - b2) <= 1: print("YES") if c2 == b2: print(" ".join("01" * a + "21" * c2 + "23" * d)) elif c2 == b2 - 1: print(" ".join("1" + "01" * a + "21" * (b2 - 1) + "23...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING BIN_OP BIN_OP BIN_OP STRING VAR BIN_OP STRING VAR BIN_OP STRING VAR ...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a, b, c, d = map(int, input().split()) x1 = b - a x2 = c - d if b == 0 and a == 0 and abs(c - d) <= 1: if c <= d: print("YES") if d == 1 and c == 0: ans = [3] else: ans = [3, 2] * c + [3] * (d - c) print(*ans) else: print("YES") if c == 1 a...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR BIN_OP BIN_OP LIST NUMBER NUMBER VAR BIN_OP LI...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a, b, c, d = list(map(int, input().split())) try: assert abs(a - b + c - d) < 2 ans = [] if not d: ans = [1, 0] * a + [1, 2] * c if a + c < b: ans.append(1) if a + c > b: ans.pop(0) elif not a: ans = [2, 3] * d + [2, 1] * b if d + b < c: ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR LIST IF VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER NUMBER VAR BIN_OP LIST NUMBER NUMBER VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR VAR EXPR FUNC_CA...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a, b, c, d = map(int, input().split()) for st in range(4): list = [a, b, c, d] path = [] while True: if list[st] == 0: break list[st] -= 1 path.append(st) if st == 0: st = 1 elif st == 3: st = 2 elif st == 1: if ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST VAR VAR VAR VAR ASSIGN VAR LIST WHILE NUMBER IF VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER NUMBER VAR NUMBER...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a, b, c, d = map(int, input().split()) sol = [] if a == 0 and b == 0: if abs(c - d) <= 1: if c == d: for i in range(c): sol.append(2) sol.append(3) elif c == d + 1: for i in range(d): sol.append(2) sol.append(3) ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST IF VAR NUMBER VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
def getAns(a, b, c, d): if a > b: if a - b == 1 and c == 0 and d == 0: print("YES") li = [] li.append(0) for i in range(b): li.append(1) li.append(0) print(*li) return print("NO") return ...
FUNC_DEF IF VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN EXPR FUNC_CALL VAR STRING RETURN IF VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMB...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a, b, c, d = list(map(int, input().split())) n1 = a n2 = b n3 = c n4 = d l = list() a1 = a a2 = b c1 = 0 c2 = 1 k = 0 f = 1 g1 = 1 g2 = 1 ans1 = 1 for i in range(0, a + b + c + d): if a == 0 and g1: g1 = 0 a = c c1 = 2 if b == 0 and g2: g2 = 0 b = d c2 = 3 if ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
import sys def rint(): return map(int, sys.stdin.readline().split()) def input(): return sys.stdin.readline().rstrip("\n") def oint(): return int(input()) a, b, c, d = rint() tot = a + b + c + d ans = [] if a > b + 1 or d > c + 1: print("NO") exit() if a == b + 1: if c != 0 or d != 0: ...
IMPORT FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR LIST IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL V...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
import sys input = sys.stdin.readline A, B, C, D = map(int, input().split()) if A + C == B + D: if B >= A and C >= D: print("YES") ans = [] for _ in range(D): ans.append(3) ans.append(2) for _ in range(C - D): ans.append(1) ans.append(...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBE...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a, b, c, d = map(int, input().split()) if not -1 <= a + c - b - d <= 1: print("NO") exit() if a + b and d - c > 0 or c + d and a - b > 0: print("NO") exit() if not a + b: ansls = [2] * (c > d) + [3, 2] * min(c, d) + [3] * (d > c) print("YES") print(*ansls) elif not c + d: ansls = [1] * (...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF NUMBER BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF BIN_OP VAR VAR BIN_OP VAR VAR NUMBER BIN_OP VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF BIN_OP VAR VAR ASSIGN VAR BIN_O...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a, b, c, d = [int(x) for x in input().split()] res = [(0) for _ in range(a)] res += [(2) for _ in range(c)] if a + c < b + d: ind = 0 else: ind = 1 while b > 0: res.insert(ind, 1) ind += 2 b -= 1 while d > 0: res.insert(ind, 3) ind += 2 d -= 1 tr = True for i in range(1, len(res)): i...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR ...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
n0, n1, n2, n3 = map(int, input().split()) if n2 + n3 == 0: if n0 == n1: print("YES") for i in range(n0): print(0, 1, end=" ") elif abs(n0 - n1) == 1: print("YES") if n0 < n1: print(1, end=" ") for i in range(n0): print(0, 1, en...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER STRING IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR NUMBER STRING FOR VAR FUNC_CALL ...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
import sys readline = sys.stdin.readline def check(A, B, C, D): N = A + B + C + D if not (A + C == N // 2 or A + C == -(-N // 2)): return False even = [2] * C + [0] * A odd = [3] * D + [1] * B ans = [None] * N flag = B + D == -(-N // 2) for i in range(N): if (i % 2 == 0) =...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR IF BIN_OP VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR BIN_OP VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NONE VA...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
import sys input = sys.stdin.readline a, b, c, d = map(int, input().split()) if a > b + 1: print("NO") elif a == b + 1: if c == d == 0: print("YES") arr = [0] + [1, 0] * b print(*arr) else: print("NO") elif d > c + 1: print("NO") elif d == c + 1: if a == b == 0: ...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER BIN_OP LIST NUMBER NUMBER VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING IF V...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
_count = list(map(int, input().split())) num = "0 1 2 3".split() for pos in range(4): count = _count[:] ans = [] for i in range(sum(count)): ans.append(num[pos]) count[pos] -= 1 if pos == 1: if count[0] > 0: pos = 0 else: pos = ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL STRING FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBE...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
def printit(s): print("YES") print(*s) exit() def solve(j, i): tt = sum(j) jj = [] for nn in j: jj.append(nn) s = [] while 1: if i == 4 or jj[i] == 0: break s.append(i) jj[i] -= 1 if i > 0 and jj[i - 1] > 0: i -= 1 ...
FUNC_DEF EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST WHILE NUMBER IF VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR ...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
import sys def Solve1(A, s, t): seq = list(range(s, t + 1)) for i in seq: A[i] -= 1 if any(A[i] < 0 for i in range(4)): return None if any(A[i] > 0 for i in range(4)): lo = min(i for i in range(4) if A[i] > 0) hi = max(i for i in range(4) if A[i] > 0) if any(A[i...
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER RETURN NONE IF FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL ...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
def sexy(a): a.append(0) k = sum(a) b = a[:] s0 = [] s1 = [] i = 0 j = 1 c = 0 while True: if c % 2 == 0: while a[i] == 0 and i < 4: i += 1 if i == 4: break if i == j: i += 1 w...
FUNC_DEF EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF BIN_OP VAR NUMBER NUMBER WHILE VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER IF VAR VAR VAR NUMBER WHILE VAR VAR NUMBER VAR NUMBER VAR...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a, b, c, d = map(int, input().split()) if a > b + 1 or b > a + c + 1 or c > b + d + 1 or d > c + 1: print("NO") else: d1 = d d2 = d L1 = ["k"] L2 = ["k"] for i in range(a): L1.append(0) L1.append("k") L2.append(0) L2.append("k") for i in range(c): L1.a...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST STRING ASSIGN VAR LIST STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
import sys from sys import stdin, stdout def ispossible(a, b, c, d): if ( b >= a - 1 and c >= d - 1 and (b - a == c - d or b - a + 1 == c - d or b - a == c - d + 1) ): return True else: return False A = stdin.readline().strip().split() a = int(A[0]) b = int(A[1]) ...
IMPORT FUNC_DEF IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR N...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
from sys import stdin input = stdin.readline a, b, c, d = map(int, input().split()) if abs(a + c - b - d) > 1: print("NO") exit(0) ans = [-1] for i in range(a + c): if i < c: ans.append(2) ans.append(-1) else: ans.append(0) ans.append(-1) def check(lst): pre = -1 ...
ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
import sys input = sys.stdin.readline a, b, c, d = map(int, input().split()) for start in range(4): ANS = [] now = start A = [a, b, c, d] if A[now] == 0: continue while True: A[now] -= 1 ANS.append(now) if now == 0: if A[1] != 0: now = 1 ...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR LIST VAR VAR VAR VAR IF VAR VAR NUMBER WHILE NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VA...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a, b, c, d = map(int, input().split()) if a > b and (d != 0 or c != 0): print("NO") elif a == 1 and b == 0 and c == 0 and d == 0: print("YES") print(0) elif a == 0 and b == 1 and c == 0 and d == 0: print("YES") print(1) elif a == 0 and b == 0 and c == 1 and d == 0: print("YES") print(2) elif...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBE...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a, b, c, d = map(int, input().split()) length = min(a, b) a, b = a - length, b - length answer = [0, 1] * length length = min(c, d) c, d = c - length, d - length answer.extend([2, 3] * length) length = min(b, c) b, c = b - length, c - length answer.extend([2, 1] * length) if a > 0: answer.append(0) a -= 1 if b ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP LIST NUMBER NUMBER VAR ASSIGN VA...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a, b, c, d = map(int, input().split()) if a > b + 1 or d > c + 1: print("NO") elif a == b + 1: if c == d == 0: print("YES") print("0 1 " * b + " 0") else: print("NO") elif d == c + 1: if a == b == 0: print("YES") print("3 2 " * c + " 3") else: print("N...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING VAR STRING EXPR FUNC_CALL VAR STRING IF VAR BIN_OP VAR NUMBER IF VAR VAR ...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
def find_start_old(freq): largest = max(freq) if freq.count(largest) == 1 or freq[0] == largest: return freq.index(largest) if freq[-1] == largest: return 3 if freq[0] > freq[-1]: return 2 return 1 def find_start(freq): temp = [0] + freq + [0] diff = [(temp[i] - tem...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR RETURN FUNC_CALL VAR VAR IF VAR NUMBER VAR RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR BIN_OP BIN_OP LIST NUMBER VAR LIST NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP V...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
import sys a, b, c, d = map(int, input().split()) x = [] y = [] for i in range(a): x.append(0) for i in range(b): y.append(1) for i in range(c): x.append(2) for i in range(d): y.append(3) p = [] if len(x) < len(y): x, y = y, x i = 0 j = 0 if len(x) != len(y): p.append(x[0]) j += 1 x, y ...
IMPORT ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN V...
You are given a binary matrix $A$ of size $n \times n$. Rows are numbered from top to bottom from $1$ to $n$, columns are numbered from left to right from $1$ to $n$. The element located at the intersection of row $i$ and column $j$ is called $A_{ij}$. Consider a set of $4$ operations: Cyclically shift all rows up. Th...
import sys def main(): input = sys.stdin if len(sys.argv) >= 2: input = open(sys.argv[1], "r") n = int(input.readline().strip()) for i in range(n): input.readline() size = int(input.readline().strip()) mtrx = [[int(t) for t in input.readline().strip()] for i in range(si...
IMPORT FUNC_DEF ASSIGN VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR ...
You are given a binary matrix $A$ of size $n \times n$. Rows are numbered from top to bottom from $1$ to $n$, columns are numbered from left to right from $1$ to $n$. The element located at the intersection of row $i$ and column $j$ is called $A_{ij}$. Consider a set of $4$ operations: Cyclically shift all rows up. Th...
def minburles(matrix): n = len(matrix) num1 = 0 numd = 0 for j0 in range(n): j = j0 cnt = 0 for i in range(n): if matrix[i][j] == 1: cnt += 1 num1 += 1 j += 1 j %= n numd = max(numd, cnt) return n + n...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN BIN_OP BIN_OP VAR VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CA...
You are given a binary matrix $A$ of size $n \times n$. Rows are numbered from top to bottom from $1$ to $n$, columns are numbered from left to right from $1$ to $n$. The element located at the intersection of row $i$ and column $j$ is called $A_{ij}$. Consider a set of $4$ operations: Cyclically shift all rows up. Th...
def intlist(): return [int(i) for i in input()] def solve(): pp = input() n = int(input()) l = [] oness = 0 for i in range(n): ll = intlist() oness += ll.count(1) l.append(ll + ll) ma = 0 for i in range(0, n): d = 0 for j in range(0, n): ...
FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ...
You are given a binary matrix $A$ of size $n \times n$. Rows are numbered from top to bottom from $1$ to $n$, columns are numbered from left to right from $1$ to $n$. The element located at the intersection of row $i$ and column $j$ is called $A_{ij}$. Consider a set of $4$ operations: Cyclically shift all rows up. Th...
for _ in range(int(input())): input() n = int(input()) x = 0 mat = [] ans = 0 for i in range(n): temp = input() mat.append(temp) x += temp.count("1") for i in range(n): cur = 0 for j in range(n): if mat[j][(j + i) % n] == "1": ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL...
You are given a binary matrix $A$ of size $n \times n$. Rows are numbered from top to bottom from $1$ to $n$, columns are numbered from left to right from $1$ to $n$. The element located at the intersection of row $i$ and column $j$ is called $A_{ij}$. Consider a set of $4$ operations: Cyclically shift all rows up. Th...
for i in range(int(input())): input() ans, size = 0, int(input()) matrix = [list(map(int, list(input()))) for line in range(size)] diagonals = [] for x in range(size): diagonals.append(sum(matrix[y][(x + y) % size] for y in range(size))) best = sorted(diagonals)[-1] print(str(size - ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR...
You are given a binary matrix $A$ of size $n \times n$. Rows are numbered from top to bottom from $1$ to $n$, columns are numbered from left to right from $1$ to $n$. The element located at the intersection of row $i$ and column $j$ is called $A_{ij}$. Consider a set of $4$ operations: Cyclically shift all rows up. Th...
def solution(): newline = input() n = int(input()) A = [] count_one = 0 for _ in range(n): row = [int(i) for i in input()] A.append(row) count_one += sum(row) max_one = 0 for i in range(n): record = 0 for j in range(n): record += A[j][(i + ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR...
You are given a binary matrix $A$ of size $n \times n$. Rows are numbered from top to bottom from $1$ to $n$, columns are numbered from left to right from $1$ to $n$. The element located at the intersection of row $i$ and column $j$ is called $A_{ij}$. Consider a set of $4$ operations: Cyclically shift all rows up. Th...
def solve(): input() n = int(input()) matrix = tuple(tuple(int(i) for i in iter(input())) for _ in range(n)) cached = tuple(sum(matrix[k][k + i - n] for k in range(n)) for i in range(n)) print(sum(cached) + n - 2 * max(cached)) for _ in range(int(input())): solve()
FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP...
You are given a binary matrix $A$ of size $n \times n$. Rows are numbered from top to bottom from $1$ to $n$, columns are numbered from left to right from $1$ to $n$. The element located at the intersection of row $i$ and column $j$ is called $A_{ij}$. Consider a set of $4$ operations: Cyclically shift all rows up. Th...
T = int(input()) while T > 0: T -= 1 input() n = int(input()) arr = [] for i in range(n): tmp = input() arr.append(tmp) ans = 0 cnt = 0 for i in range(n): tmp = 0 for j in range(n): if arr[j][(i + j) % n] == "1": tmp += 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR...
You are given a binary matrix $A$ of size $n \times n$. Rows are numbered from top to bottom from $1$ to $n$, columns are numbered from left to right from $1$ to $n$. The element located at the intersection of row $i$ and column $j$ is called $A_{ij}$. Consider a set of $4$ operations: Cyclically shift all rows up. Th...
t = int(input()) while t: n = input() if n != "": n = int(n) ones = [0] * n for turn in range(n): s = input() for i in range(n): if s[i] == "1": ones[i - turn] = ones[i - turn] + 1 print(sum(ones) - max(ones) + n - max(o...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR IF VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL ...
You are given a binary matrix $A$ of size $n \times n$. Rows are numbered from top to bottom from $1$ to $n$, columns are numbered from left to right from $1$ to $n$. The element located at the intersection of row $i$ and column $j$ is called $A_{ij}$. Consider a set of $4$ operations: Cyclically shift all rows up. Th...
for _ in range(int(input())): input() n = int(input()) a = [list(map(int, input())) for _ in range(n)] s = sum(map(sum, a)) u = max(sum(a[i][(i + d) % n] for i in range(n)) for d in range(n)) print(n - u + (s - u))
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR FUNC_CALL...
You are given a binary matrix $A$ of size $n \times n$. Rows are numbered from top to bottom from $1$ to $n$, columns are numbered from left to right from $1$ to $n$. The element located at the intersection of row $i$ and column $j$ is called $A_{ij}$. Consider a set of $4$ operations: Cyclically shift all rows up. Th...
def count(b, n): l = [] for i in range(n): c = 0 for j in range(n): if b[j][j - i] == "1": c += 1 l.append(c) return l for i in range(int(input())): s = input() n = int(input()) p = [] for j in range(n): p.append(input()) s = ...
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL...
You are given a binary matrix $A$ of size $n \times n$. Rows are numbered from top to bottom from $1$ to $n$, columns are numbered from left to right from $1$ to $n$. The element located at the intersection of row $i$ and column $j$ is called $A_{ij}$. Consider a set of $4$ operations: Cyclically shift all rows up. Th...
T = int(input()) q = [] for i in range(T): input() n = int(input()) m = [] for i in range(n): c = input() m.append(c) q.append((n, m)) def solve(n, mat): max_long = 0 id = -1 counter = [] for r in range(n): tot = 0 for j in range(n): c = ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR...
You are given a binary matrix $A$ of size $n \times n$. Rows are numbered from top to bottom from $1$ to $n$, columns are numbered from left to right from $1$ to $n$. The element located at the intersection of row $i$ and column $j$ is called $A_{ij}$. Consider a set of $4$ operations: Cyclically shift all rows up. Th...
t = int(input()) for _ in range(t): input() n = int(input()) sum_per_diagonal = [0] * n for i in range(n): digits = input() for j, digit in enumerate(digits): sum_per_diagonal[(n + j - i) % n] += digit == "1" print(sum(sum_per_diagonal) + n - 2 * max(sum_per_diagonal))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_...
You are given a binary matrix $A$ of size $n \times n$. Rows are numbered from top to bottom from $1$ to $n$, columns are numbered from left to right from $1$ to $n$. The element located at the intersection of row $i$ and column $j$ is called $A_{ij}$. Consider a set of $4$ operations: Cyclically shift all rows up. Th...
def solve(): ans = 0 for s in range(n): i = 0 j = s diag = 0 while i < n: if matrix[i][j] == "1": diag += 1 i += 1 j += 1 if j == n: j = 0 ans = max(ans, diag) return ans for _ in range(...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR STRING VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR...
You are given a binary matrix $A$ of size $n \times n$. Rows are numbered from top to bottom from $1$ to $n$, columns are numbered from left to right from $1$ to $n$. The element located at the intersection of row $i$ and column $j$ is called $A_{ij}$. Consider a set of $4$ operations: Cyclically shift all rows up. Th...
for _ in range(int(input())): thousandminusseven = input() n = int(input()) a = [input() for _ in range(n)] for i in range(1, n): a[i] = a[i][i:n] + a[i][:i] cnt = sum(sum(c == "1" for c in t) for t in a) bans = n**2 mxc = max(sum(a[i][j] == "1" for i in range(n)) for j in range(n)) ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR STRING VAR VAR VAR VAR ASSIGN VAR...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
t = int(input()) ret = [] for ii in range(t): n = int(input()) d = list(map(int, input().split())) ans = 10**18 for i in range(3): for j in range(3): some3 = 0 flg = True for k in range(n): if d[k] == 1 and i == 0: flg = Fal...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
t = int(input()) def get_sum_3(count): return count[3] + min(count[2], count[1]) + max(0, count[1] - count[2]) // 3 for i in range(t): count = [0, 0, 0, 0] n = int(input()) a = [int(x) for x in input().split(" ")] a.sort() a = a[::-1] may3 = 0 for j in range(n): div = a[j] //...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER BIN_OP FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VA...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
def find(n, L): if n == 1: return int((L[0] - 1) / 3) + 1 r0 = [] r1 = [] r2 = [] for elem in L: r = elem % 3 if r == 0: r0.append(elem) elif r == 1: r1.append(elem) else: r2.append(elem) x = max(L) if x % 3 == 0: ...
FUNC_DEF IF VAR NUMBER RETURN BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_O...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
def solve(): N = int(input()) A = list(map(int, input().split())) mA = max(A) sA = set(a % 3 for a in A) sA2 = set(A) if len(sA) == 1: if mA % 3 == 0: print(mA // 3) else: print(mA // 3 + 1) elif len(sA) == 2: if 0 in sA and 1 in sA: ...
FUNC_DEF 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 ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXP...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
import sys t = int(sys.stdin.readline()) for _ in range(t): n = int(sys.stdin.readline()) st = set(map(int, sys.stdin.readline().split())) mx = max(st) if mx == 1: print(1) continue arr = set(x % 3 for x in st) if mx % 3 == 0: print(mx // 3 + int(1 in arr or 2 in arr)) ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR IF BIN_OP VAR NUMBER N...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
from sys import stdin input = stdin.readline def check(x, y, z): for i in range(n): if 3 * x + 2 * y + z < a[i]: return False take = a[i] // 3 yes = False for req in range(max(0, take - 2), min(x + 1, take + 1)): for j in range(y + 1): for k...
ASSIGN VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP ...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
t = int(input()) for i in range(t): n = int(input()) lst = list(map(int, input().split())) m = max(lst) c1 = 0 c2 = 0 for j in lst: if j % 3 == 1: c1 += 1 elif j % 3 == 2: c2 += 1 if m % 3 == 0: if c1 == 0 and c2 == 0: print(m // 3)...
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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR N...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
import sys tokens = "".join(sys.stdin.readlines()).split()[::-1] def next(): return tokens.pop() def nextInt(): return int(next()) def nextFloat(): return float(next()) def getIntArray(n): return [nextInt() for _ in range(n)] def getFloatArray(n): return [nextFloat() for _ in range(n)] ...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL STRING FUNC_CALL VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VA...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
def solve(): N = int(input()) a = list(map(int, input().split())) r = [0, 0, 0] M = max(a) for i in range(N): r[a[i] % 3] |= 1 if M % 3 == 0: if r[1] | r[2] == 1: print(M // 3 + 1) else: print(M // 3) elif M % 3 == 1: if r[2] == 0 or M ...
FUNC_DEF 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 NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CAL...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
t = int(input()) for q in range(t): n = int(input()) lis = list(map(int, input().split())) lis.sort() suslis = [(i % 3) for i in lis] maxi = max(lis) if maxi % 3 == 0: if suslis == [(0) for i in lis]: print(maxi // 3) else: print(maxi // 3 + 1) elif ma...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR NUMBER VAR VAR EXPR FUNC_CALL...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
t = int(input()) for c in range(t): n = int(input()) a = sorted(list(set(map(int, input().split())))) m = a[-1] k = max([(x // 3) for x in a]) mod3s = sorted(list(set([(x % 3) for x in a]))) if mod3s == [0]: ans = k elif mod3s == [1]: ans = k + 1 elif mod3s == [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 FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
import sys inpu = sys.stdin.readline prin = sys.stdout.write I = lambda: [*map(int, inpu().split())] t = I()[0] for _ in range(t): (n,) = I() a = I() m = max(a) x = m % 3 if x == 0: bad = False for guy in a: if guy % 3 != 0: bad = True bre...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR N...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) b = [0, 0, 0, 0] sum = 0 ma = 0 for x in a: ma = max(ma, x) if x == 1: b[3] = 1 b[x % 3] = 1 sum = max(sum, x // 3) if (b[1] == 1) & (b[2] == 1): bb = ...
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 NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
t = int(input()) while t > 0: t = t - 1 n = int(input()) a = list(map(int, input().split())) a.sort() b = [0, 0, 0] for i in range(n): b[a[i] % 3] += 1 if a[n - 1] % 3 == 0: if b[1] == 0 and b[2] == 0: print(a[n - 1] // 3) else: print(a[n - 1] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER NUMBER IF BIN_OP VAR ...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
for _ in range(int(input())): n = int(input()) l = list(map(int, input().split())) l6 = all([(x < 6) for x in l]) b = 2000000000.0 for i in range(7): for j in range(4): for k in range(3): ok = [ True, i > 0, ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
t = int(input()) ans = [] for _ in range(t): n = int(input()) a = list(map(int, input().split())) m = max(a) k1 = 0 k2 = 0 for elem in a: if elem % 3 == 1: k1 = 1 elif elem % 3 == 2: k2 = 1 if m % 3 == 0: if k1 or k2: ans.append(m /...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF BIN_OP ...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
t = int(input()) for case in range(t): n = int(input()) stuff = [int(x) for x in input().split(" ")] needs1 = 0 needs2 = 0 all3 = True mini = float("inf") maxi = 0 anothercondition = 0 has3 = False for x in stuff: if x % 3 == 1: needs1 = 1 all3 = F...
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 STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
import sys input = sys.stdin.readline for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) mods = [0, 0, 0] for i in arr: mods[i % 3] += 1 m = max(arr) if m % 3 == 0: if mods[1] == 0 and mods[2] == 0: print(m // 3) else: ...
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER FOR VAR VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR ...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
t = int(input()) for _ in range(t): n = int(input()) m = list(map(int, input().split())) m.sort() m1 = 0 m2 = 0 m3 = 0 m1m = 0 m2m = 0 for i in m: m3 = i // 3 if i == 1: m1m = 1 if i == 2: m2m = 1 if i % 3 == 1: m1 =...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
from sys import maxsize for _ in range(int(input())): n = int(input()) l = list(map(int, input().split())) ok1, ok2, ok3, ok4, ok5 = 0, 0, 0, 0, 0 v = maxsize for i in range(n): if l[i] % 3 != 0: ok1 = v break ok1 = max(ok1, l[i] // 3) for i in range(n): ...
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 VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR FUN...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
ans = [] for p in range(int(input())): cnt = 0 price = [] u = int(input()) mas = input().split() for i in range(u): mas[i] = int(mas[i]) ost1 = 0 ost2 = 0 for i in mas: if i % 3 == 1: ost1 = 1 if ost2 == 1: break if i % 3 ==...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR 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 ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN ...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
import sys t = int(sys.stdin.readline()) while t: t -= 1 n = int(input()) dat = list(set(list(map(int, sys.stdin.readline().split())))) dat.sort() res = [] for i in range(len(dat)): res.append(dat[i] % 3) ost = dat[-1] % 3 ans = dat[-1] // 3 if ost == 0: if 1 in res ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASS...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
for _ in range(int(input())): n = int(input()) l = list(map(int, input().split())) mc = max(l) if mc == 1: ans = 1 else: hasone = 1 in l extras = set(num % 3 for num in l if num != mc) extras.discard(0) q, r = divmod(mc, 3) closecall = any(mc > num >= ...
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 VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR VAR EXPR FUNC_CALL VAR NUM...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
def solver(): n = int(input()) for _ in range(n): n_flavors = int(input()) cost_flavors = list(reversed(sorted(list(map(int, input().split()))))) final = {} checker = True for i in cost_flavors: if checker: final[3] = final.get(3, 0) + i // 3 ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR IF VAR ASSIGN VAR NUMBER BIN_OP FUNC_CALL VAR NUMBER...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
import sys def exact_change(n, a): a.sort() _1 = 0 _2 = 0 for ai in a: r = ai % 3 if r == 1: _1 = 1 elif r == 2: _2 = 1 r = a[-1] % 3 if r == 0: if _1 == 1 or _2 == 1: return a[-1] // 3 + 1 return a[-1] // 3 if r =...
IMPORT FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER IF VAR NUMBER IF VAR NUMBER VAR NUMBER RETURN BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER RETURN BIN_OP VAR NUMBE...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
def mincoin(arr): zero = 0 num3 = max(arr) // 3 - 1 mid = num3 * 3 + 3 lower = [0, 0, 0] upper = [0, 0] for i in arr: if i < mid: lower[i % 3] = 1 elif i == mid: zero = 1 else: upper[i % 3 - 1] = 1 lower[0] = zero if sum(upper) ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NU...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
for _ in range(int(input())): n = int(input()) nums = list(map(int, input().split())) nums.sort() max_num = nums[-1] remainder_1, remainder_2 = False, False for num in nums: if num % 3 == 1: remainder_1 = True if num % 3 == 2: remainder_2 = True if max...
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 ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN V...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
def possible2(ai, c1, c2, c3): for cc1 in range(c1 + 1): for cc2 in range(c2 + 1): if cc1 + 2 * cc2 > ai: continue if (ai - cc1 - 2 * cc2) % 3 == 0 and (ai - cc1 - 2 * cc2) // 3 <= c3: return True return False def possible(a, c1, c2, c3): for...
FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR VAR IF BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP NUMBER VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP NUMBER VAR NUMBER VAR RETURN NUMBER RETURN NUMBER FUNC_DEF FOR VAR VAR IF FUNC_CALL VAR VAR VAR...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
import sys def ec(n, l1): ans1 = 0 ans2 = 0 ans3 = 0 i = 0 while i < len(l1): if l1[i] % 3 != 0: ans1 = sys.maxsize break i = i + 1 if i == len(l1): ans1 = max(l1) // 3 i = 0 while i < len(l1): if l1[i] % 3 == 2: ans2 ...
IMPORT FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF BIN_OP VAR ...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
import sys input = lambda: sys.stdin.readline().rstrip() INF = 10**19 def solve(): n = int(input()) a = list(map(int, input().split())) ans = INF cnt = 0 for i in range(n): if a[i] % 3 != 0: cnt = INF break cnt = max(cnt, a[i] // 3) ans = min(cnt, ans) ...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR ...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
import sys input = sys.stdin.readline test = int(input()) for i in range(test): count = int(input()) price = list(map(int, input().split())) max_ = 0 mod = [False, False, False] for i in range(count): if price[i] > max_: max_ = price[i] mod[price[i] % 3] = True if mo...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR B...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
t = int(input()) for i in range(t): n = int(input()) a = list(map(int, input().split())) x = max(a) r = [] for i in range(n): r.append(a[i] % 3) rx = x % 3 ans = x // 3 if rx == 0: if 1 in r or 2 in r: ans += 1 if rx == 1: ans += 1 if 2 in ...
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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN V...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
def p(v, x, y, z): for i in range(x + 1): for j in range(y + 1): if i + 2 * j > v: continue if (v - i - 2 * j) % 3 != 0: continue if (v - i - 2 * j) / 3 <= z: return True return False def possible(a, x, y, z): for ...
FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR VAR IF BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP NUMBER VAR NUMBER NUMBER IF BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP NUMBER VAR NUMBER VAR RETURN NUMBER RETURN NUMBER FUNC_DEF FOR VAR VAR IF FUNC_CALL VAR VAR ...
One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which one to buy after arriving there. But there are two major flaws in thi...
for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) arr = list(set(arr)) a = [] zeroes, ones, twos = 0, 0, 0 for i in arr: a.append(i // 3) if i % 3 == 1: ones += 1 elif i % 3 == 2: twos += 1 else: ...
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 FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NU...