description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | def check(stx, sty, x, y):
for i in range(stx, stx + x):
for j in range(sty, sty + y):
if g[i][j] != g[stx][sty]:
return False
return True
n, m = map(int, input().split())
g = [input() for i in range(n)]
if (
n % 3 == 0
and check(0, 0, n // 3, m)
and check(n // ... | FUNC_DEF FOR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR IF VAR VAR VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR NUMBER NUMBER BIN_OP VAR NUM... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | def is_horizontal():
if n % 3 == 0:
colors = {}
diff_colors = set()
stripe_hight = n // 3
for k in range(3):
colors[k] = flag[k * stripe_hight][0]
diff_colors.add(colors[k])
for i in range(k * stripe_hight, k * stripe_hight + stripe_hight):
... | FUNC_DEF IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR RETU... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | n, m = (int(i) for i in input().split())
flag = []
for i in range(n):
flag += [input()]
count = {"R": 0, "G": 0, "B": 0}
for line in flag:
for let in line:
count[let] += 1
check1 = True
change1 = 0
for i in range(n):
if i < n - 1 and flag[i][0] != flag[i + 1][0]:
change1 += 1
for j in ra... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR VAR LIST FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER FOR VAR VAR FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR NU... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | n, m = list(map(int, input().split()))
field = [input() for i in range(n)]
if n % 3 == 0:
size = n // 3
flag = True
block = set()
stripes = set()
for i in range(n):
if i % size == 0:
block = set()
for j in range(m):
block.add(field[i][j])
if (i + 1) % ... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR F... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | n, m = map(int, input().split())
fl = [input() for i in range(n)]
c1 = fl[0][0]
BOOL = False
for i in range(n):
if fl[i][0] != c1:
BOOL = True
break
if BOOL:
BOOL = False
if n % 3 == 0:
for i in range(n // 3)[: n // 3]:
for j in range(m):
if fl[i][j] != c1... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | n, _ = map(int, input().split())
s = input()
n -= 1
a = ""
k = 0
if "R" in s:
k += 1
if "G" in s:
k += 1
if "B" in s:
k += 1
t = 1
if k > 1:
a = s
for _ in range(n):
s1 = input()
if s1 != s:
t = 0
break
elif k == 1:
a += s[0]
for _ in range(n):
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER IF STRING VAR VAR NUMBER IF STRING VAR VAR NUMBER IF STRING VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR IF VAR VAR ASSIGN ... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | def satisfy_line(line):
total = len(line)
size = total // 3
if total % 3 != 0:
return False
first_part = line[0:size]
second_part = line[size : 2 * size]
third_part = line[2 * size : 3 * size]
first_set = set(first_part)
second_set = set(second_part)
third_set = set(third_par... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR VAR BIN_OP NUMBER VAR ASSIGN VAR VAR BIN_OP NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CA... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | import sys
input = sys.stdin.readline
n, m = map(int, input().split())
a = [list(input().rstrip()) for i in range(n)]
tate = True
yoko = True
if n < 3:
yoko = False
if m < 3:
tate = False
for i in range(n - 1):
if a[i][0] != a[i + 1][0]:
tate = False
for j in range(m - 1):
if a[0][j] != a[0][j ... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR BIN_OP V... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | n, m = map(int, input().split())
A = [input() for _ in range(n)]
if n % 3 == 0:
k = n // 3
s1 = set()
s2 = set()
s3 = set()
for i in range(k):
for j in range(m):
s1.add(A[i][j])
for i in range(k, 2 * k):
for j in range(m):
s2.add(A[i][j])
for i in rang... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR F... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | n, m = [int(el) for el in input().split()]
fl = [input().split() for i in range(n)]
fl1 = (
[["R" * m] for i in range(n // 3)]
+ [["G" * m] for i in range(n // 3)]
+ [["B" * m] for i in range(n // 3)]
)
fl2 = (
[["R" * m] for i in range(n // 3)]
+ [["B" * m] for i in range(n // 3)]
+ [["G" * m] ... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP LIST BIN_OP STRING VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER LIST BIN_OP STRING VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER LIST BIN_OP STRING VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | def f(n, m, a):
d = dict()
if n % 3 == 0:
k = n // 3
else:
return False
c = a[0][0]
d = {}
d[1] = c
for i in range(k):
for j in range(m):
if c == a[i][j]:
pass
else:
return False
c = a[k][0]
d[2] = c
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER VAR FOR VAR FUNC_CA... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | b, k = map(int, input().split())
arr = []
for i in range(b):
s = input()
arr.append(s)
x = arr[0][0]
nb = 1
nk = 1
pola = str(x)
while nk < k and arr[0][nk] == x:
nk += 1
pola += x
if nk == k or nk == k / 3:
if nk == k / 3:
arr = list(map(lambda x: "".join(x), map(list, zip(*arr))))
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR NUMBER VAR VAR VAR NUMBER VAR VAR IF VAR VAR VAR BIN_OP VAR N... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | n, m = list(map(int, input().split()))
flag = []
def letterwidth(i):
res = flag[i][0]
for item in flag[i]:
if item != res:
return None
return res
def letterheight(i):
res = flag[0][i]
for j in range(n):
if flag[j][i] != res:
return None
return res
fo... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF ASSIGN VAR VAR VAR NUMBER FOR VAR VAR VAR IF VAR VAR RETURN NONE RETURN VAR FUNC_DEF ASSIGN VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR RETURN NONE RETURN VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | def check(a):
cur = a[0][0]
d = {}
for p in a:
if p[0] != cur and p[0] in d:
return 0
cur = p[0]
if not all([(x == cur) for x in p]):
return 0
d[cur] = d.get(cur, 0) + 1
if len(d) != 3:
return 0
if not "R" in d or not "G" in d or not "B... | FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR DICT FOR VAR VAR IF VAR NUMBER VAR VAR NUMBER VAR RETURN NUMBER ASSIGN VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER IF STRING VAR STRING VAR STRING VAR RETURN... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | n, m = list(map(int, input().split()))
ls = []
for i in range(n):
ls.append(input())
if ls[0] != "R" * m and ls[0] != "G" * m and ls[0] != "B" * m:
ls1 = []
for i in range(m):
row = ""
for j in range(n):
row += ls[j][i]
ls1.append(row)
ls = ls1
m = n
n = len(l... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER BIN_OP STRING VAR VAR NUMBER BIN_OP STRING VAR VAR NUMBER BIN_OP STRING VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VA... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | def solve(h, w, f):
if h % 3:
return False
a = f[0][0]
b = f[h // 3][0]
c = f[2 * h // 3][0]
if a == b or b == c or c == a:
return False
for y in range(h // 3):
if f[y].count(a) != w:
return False
for y in range(h // 3, 2 * h // 3):
if f[y].count(b... | FUNC_DEF IF BIN_OP VAR NUMBER RETURN NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER IF VAR VAR VAR VAR VAR VAR RETURN NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR RETURN NUMBER FOR VAR FUNC_CALL VAR BIN_OP ... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | n, m = list(map(int, input().split(" ")))
ls, col = [], []
for x in range(n):
ls.append(input())
for i in range(m):
elem = ""
for x in ls:
elem = "".join([elem, x[i]])
col.append(elem)
def ans():
if n % 3 != 0 and m % 3 != 0:
return "NO"
for x in ls:
if any(y not in ["R... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR VAR ASSIGN VAR FUNC_CALL STRING LIST VAR VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF IF BIN_OP VAR NUMBER NUMB... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | def re(a):
if a == "R":
return 0
elif a == "B":
return 1
else:
return 2
def llk(a):
dd = "".join(a)
i = 0
n = len(dd)
su = 0
while i < n - 1:
if dd[i] != dd[i + 1]:
su += 1
i += 1
if su == 2:
return 1
else:
ret... | FUNC_DEF IF VAR STRING RETURN NUMBER IF VAR STRING RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | def checkline(i):
mark = d[i][0]
for j in range(m):
if d[i][j] != mark:
return 0
return mark
def checkrow(i):
mark = d[0][i]
for j in range(n):
if d[j][i] != mark:
return 0
return mark
n, m = map(int, input().split())
if n % 3 != 0 and m % 3 != 0:
... | FUNC_DEF ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR RETURN NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR RETURN NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER ... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | class CodeforcesTask837BSolution:
def __init__(self):
self.result = ""
self.n_m = []
self.flag = []
def read_input(self):
self.n_m = [int(x) for x in input().split(" ")]
for x in range(self.n_m[0]):
self.flag.append(input())
def process_task(self):
... | CLASS_DEF FUNC_DEF ASSIGN VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR LIST IF BIN_OP VAR NU... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | n, m = map(int, input().split())
arr = [0] * n
for i in range(n):
arr[i] = input()
was = []
dist = -1
m_dist = 0
chk1 = 1
chk2 = 1
prev_ans = arr[0][0]
was.append(arr[0][0])
allowed = ["R", "B", "G"]
if not arr[0][0] in allowed:
chk1 = 0
chk2 = 0
for i in range(n):
dist += 1
for j in range(m):
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR LIST STRI... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | [n, m] = [int(i) for i in input().split()]
flag = []
flip_flag = []
for i in range(m):
flip_flag.append([])
tmp = n
while tmp:
tmp -= 1
flag.append(list(input()))
for i in range(m):
flip_flag[i].append(flag[-1][i])
if len(set(flag[0])) != 1:
flag = flip_flag
strip_count = {}
valid = True
str... | ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST ASSIGN VAR VAR WHILE VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER VAR IF FUNC_CALL VAR FUNC_CAL... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | import sys
n, m = map(int, input().split())
s = []
for i in range(n):
string = input()
s.append(string)
no = 0
r_mix = 0
for i in range(n):
cnt_r = s[i].count("R")
cnt_b = s[i].count("B")
cnt_g = s[i].count("G")
if cnt_r and cnt_b or cnt_b and cnt_g or cnt_g and cnt_r:
r_mix = 1
c_mix =... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL 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 FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR STR... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | n, m = map(int, input().split())
t = []
for i in range(n):
s = input()
t.append([])
for j in s:
t[-1].append(j)
c = -1
col = {"R": 0, "G": 0, "B": 0}
for i in range(n):
for j in range(m):
if type(t[i][j]) == str:
v = [[i, j]]
s = t[i][j]
col[s] += 1
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | N, M = map(int, input().split())
flag = [input() for n in range(N)]
def get_rect_of_color(color):
rect_points = []
for i, row in enumerate(flag):
first = True
seq_is_broken = False
tmp = [None] * 4
for j, char in enumerate(row):
if char == color:
if ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NONE NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR NU... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | import sys
def verifyFlag(flagList, row, column):
if row % 3 != 0:
return False
q = row // 3
u = [flagList[0 * q], flagList[1 * q], flagList[2 * q]]
us = set(u)
patternToMatch = set()
for color in ["R", "G", "B"]:
patternToMatch.add(color * column)
if us != patternToMatch:
... | IMPORT FUNC_DEF IF BIN_OP VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR LIST STRING STRING STRING EXPR FUNC_CALL VAR BIN_OP VAR VAR IF VAR VAR RETURN NUMBER FOR ... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | def solve_h(lines):
if len(lines) == 0:
return False
if len(lines) % 3 != 0:
return False
strip = len(lines) // 3
colors = []
for i, line in enumerate(lines):
if i % strip == 0:
colors.append(line[0])
if not all(ch == colors[-1] for ch in line):
... | FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR NUMBER VAR VAR RETURN NUMBER IF FUNC_CALL VA... |
The flag of Berland is such rectangular field n Γ m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. Each col... | n, m = map(int, input().split())
l = []
for i in range(n):
l.append([])
s = input()
for j in s:
l[i].append(j)
A = "YES"
a = True
b = True
if n % 3 != 0 and m % 3 != 0:
A = "NO"
if n % 3 == 0:
s1 = l[0][0]
for i in range(n // 3):
for j in range(m):
if l[i][j] != s1:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST ASSIGN VAR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR STRING IF BIN_O... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | import sys
input = sys.stdin.readline
t = int(input())
for you in range(t):
n = int(input())
l = input().split()
li = [(int(i) % 2) for i in l]
ind = -1
z = 0
ans = 10**12
for i in range(n):
if li[i]:
ind = i
break
if ind == -1:
print(-1)
... | 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 FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR ASS... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | for _ in range(int(input())):
n = int(input())
a = list(i % 2 for i in map(int, input().split()))
if a.count(1) == 0:
print(-1)
else:
l0, l1 = -1, -1
for i in range(n):
if a[i] % 2:
if i % 2:
l1 = i
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 BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER IF BI... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | T = int(input())
for _ in range(T):
N = int(input())
A = input().split(" ")
oePatternXor = []
eoPatternXor = []
eoPivot = -1
oePivot = -1
for i, n in enumerate(A):
V = int(n) % 2
if i % 2 == 0 and V == 0 or i % 2 == 1 and V == 1:
eoPatternXor.append(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 FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR N... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | t = int(input())
while t:
t -= 1
n = int(input())
arr = list(map(int, input().split()))
arr = [(x % 2) for x in arr]
if len(set(arr)) == 1 and arr[0] == 0:
print(-1)
continue
ans = []
s1 = [(0) for i in range(n)]
s2 = [(1) for i in range(n)]
cnt1, cnt2 = 0, 0
for ... | 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMB... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | for _ in range(int(input())):
n = int(input())
lst = list(map(int, input().strip().split()))
arr_odd = []
arr_even = []
even = 0
for i in range(len(lst)):
lst[i] = lst[i] % 2
if lst[i] == 0:
even += 1
arr_even.append(i % 2)
arr_odd.append((i + 1) % 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 FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBE... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | try:
t = int(float(input()))
for _ in range(t):
n = int(float(input()))
a = list(map(int, input().split()))
b = [(i % 2) for i in a]
if not any(b):
print(-1)
else:
oe, eo = 0, 0
o1, o2 = 0, 0
for i in range(n):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN 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 BIN_OP VAR NUMBER VAR VAR IF FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN V... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
eo = 0
oe = 0
ans = 0
for j in range(n):
if a[j] % 2 == 0:
ans += 1
if ans == n:
print(-1)
else:
for i in range(n):
if i % 2 != 0 and a[i] % 2 != 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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER FOR ... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
valid, odd, even = False, False, False
odd_pos, even_pos = -1, -1
for i in range(n):
if a[i] % 2:
valid = True
if i % 2:
odd = True
odd_pos = 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 VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER ASSIG... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | def printi(ans):
print(len(ans))
for i in ans:
print(i[0] + 1, i[1] + 1)
for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
l = [0] * len(arr)
odd = []
flag = 0
for i in range(len(arr)):
l[i] = arr[i] % 2
if arr[i] % 2 == 1:
... | FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CA... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | for _ in range(int(input())):
n = int(input())
a = [(int(x) % 2) for x in input().split()]
target1 = [(x % 2) for x in range(n)]
target2 = [((x + 1) % 2) for x in range(n)]
chk1 = chk2 = 0
changeind = -1
for i in range(n):
if a[i] != target1[i]:
chk1 += 1
elif a[i... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR ... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | from sys import stdin, stdout
inp_num = lambda: int(input())
inp_lis = lambda: list(map(int, input().split()))
for _ in range(inp_num()):
n = inp_num()
l1 = inp_lis()
l = []
re = []
re1 = []
a = 0
cou1 = -1
for i in l1:
if i % 2 == 0:
l.append(0)
else:
... | 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | t = int(input())
for _ in range(t):
n = int(input())
lst = list(map(int, input().split()))
a = []
ce = 0
co = 0
pe = 0
po = 0
for i in range(n):
if lst[i] % 2 == 0:
a.append(0)
ce = ce + 1
else:
a.append(1)
co = co + 1
i... | 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER EXP... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | for _ in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
cnt = 0
g = -1
for x in range(len(l)):
if x % 2 == 0 and l[x] % 2 == 0:
cnt = cnt + 1
elif x % 2 == 1 and l[x] % 2 == 1:
cnt = cnt + 1
if l[x] % 2 == 1:
g = ... | 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 NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | T = int(input())
for _ in range(T):
n = int(input())
A = list(map(int, input().split()))
flag = False
for i in range(n):
if A[i] % 2 == 1:
A[i] = 1
else:
A[i] = 0
first = []
second = []
no_alt_id1 = []
no_alt_id2 = []
for i in range(n):
... | 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 FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LI... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | t = int(input())
while t:
t = t - 1
n = int(input())
a = list(map(int, input().split()))
count0 = 0
count1 = 0
a0 = []
a1 = []
ans = 0
for i in range(n):
if i % 2 == 0 and a[i] % 2 == 1:
x = i
count0 = count0 + 1
if i % 2 == 1 and a[i] % 2 == 1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUM... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | def main():
n = int(input())
arr = list(map(int, input().split()))
arr1 = []
arr2 = []
t = ans = x = odd = 0
for i in range(n):
if arr[i] % 2:
odd += 1
if odd:
for i in range(n):
if arr[i] % 2 != t:
arr1.append(i)
ans +=... | 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 ASSIGN VAR LIST ASSIGN VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER IF VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER VAR EXPR FUNC_CALL VAR ... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
c = 0
o = 0
e = 0
for i in range(n):
if a[i] & 1:
c += 1
if i & 1:
o += 1
else:
e += 1
if c == 0:
print(-1)
elif o >= e:
... | 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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VA... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | def find_k(a):
e = 0
i = 0
o = 0
d = 0
for m in range(len(a)):
if a[m] % 2 != 0:
d += 1
break
else:
continue
while True:
if 2 * i >= len(a):
break
if a[2 * i] % 2 != 0:
e += 1
if a[2 * i] % 2 == 0... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER WHILE NUMBER IF BIN_OP NUMBER VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER NUMBER VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER NUMBER V... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | for t in range(int(input())):
n = int(input())
A = list(map(int, input().split()))
num = A
for i in range(n):
num[i] %= 2
if 1 in num:
eve = odd = 0
for i in range(n):
if num[i] == i % 2:
eve += 1
else:
odd += 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR NUMBER IF NUMBER VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NU... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split(" ")))
a = a[:n]
even_a = 0
even_b = 0
indices = []
op = 0
for i in range(n):
if a[i] % 2 == 0:
if i % 2 == 0:
even_a += 1
else:
even_b += 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER IF BIN_OP ... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | t = int(input())
while t > 0:
n = int(input())
a = list(map(int, input().split()))
count = 0
for i in range(n):
if a[i] % 2 == 1:
count += 1
if count == 0:
print(-1)
else:
ans1 = []
ans2 = []
oddpos = -1
evenpos = -1
ele1 = 0
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
evenI, oddI = 0, 0
even, odd, oddP = False, False, False
kE, kO = 0, 0
wE, wO = [], []
for i in range(n):
if a[i] % 2 != 0:
oddP = True
if i % 2 == 0:
even... | 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 VAR NUMBER NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | p1 = [0, 1]
p2 = [1, 0]
def parity(x):
return x & 1
for t in range(int(input())):
n = int(input())
a = tuple(map(int, input().strip().split()))
idx = 0
c1 = 0
c2 = 0
sol_exists = False
s1 = []
s2 = []
o1 = -1
o2 = -1
for i in range(n):
p = parity(a[i])
... | ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER FUNC_DEF RETURN BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | t = int(input())
while t:
n = int(input())
ls = list(map(int, input().split(" ")))
lastOddPos, evenPos, oddPos = -1, 0, 0
if [(ele % 2) for ele in ls].count(1) == 0:
print(-1)
t -= 1
continue
for i in range(1, n + 1):
if i % 2:
if ls[i - 1] % 2:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE 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 VAR VAR NUMBER NUMBER NUMBER IF FUNC_CALL BIN_OP VAR NUMBER VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
mp = -1
a = []
for i in range(n):
a.append(arr[i] & 1)
if a[i] == 1:
mp = i
if mp == -1:
print(-1)
continue
a1 = []
for i in range(1, n, 2):
if a[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 NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL V... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | def solver(n, arr):
def utility(arr):
indices = [[], []]
for i in range(n):
if parity[i] == arr[i]:
indices[parity[i]].append(i)
altered = []
for i in range(n):
if parity[i] != arr[i]:
search_val = 1
found_index... | FUNC_DEF FUNC_DEF ASSIGN VAR LIST LIST LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR IF VAR NUMBER RETURN NONE EXPR FUNC_CALL VAR VAR VAR ASSIGN V... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | for _ in range(int(input())):
l = int(input())
seq = [(int(i) % 2) for i in input().split()]
if not any(seq):
print(-1)
else:
count = [[], []]
k = 0
for i in range(l):
count[k % 2].append(i)
if i < l - 1 and seq[i] == seq[i + 1]:
k ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST LIST LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | from sys import stdin, stdout
input = stdin.readline
t = int(input())
for _ in range(t):
n = int(input())
a = [int(x) for x in input().split()]
if [(ele % 2) for ele in a].count(1) == 0:
print(-1)
continue
x = delta = 0
for i in range(n):
if a[i] % 2 != i % 2:
x ... | 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 VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL BIN_OP VAR NUMBER VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | t = int(input())
for _ in range(t):
n = int(input())
arr = list(map(int, input().split()))
odd_index_odd = []
odd_index_even = []
even_index_odd = []
even_index_even = []
count = 0
for i in range(n):
if i % 2 == 0:
if arr[i] % 2 == 0:
even_index_even.a... | 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 ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR... |
Chef loves bitwise operations. So, he creates the following problem but needs your help to solve it.
Chef calls a sequence of integers A_{1}, A_{2}, \ldots, A_{N} tasty if it satisfies the following condition:
parity(A_{i} \& A_{i+1}) \neq parity(A_{i} | A_{i+1}) for 1 β€ i < N.
Chef gives you a sequence A_{1}, A_{2},... | t = int(input())
while t:
t -= 1
n = int(input())
l = list(map(int, input().split()))
if all([(i & 1 == 0) for i in l]):
print("-1")
continue
l1 = []
l2 = []
l3 = []
odd_index = 0
for i in range(n):
if i & 1 == 0:
if l[i] & 1 == 0:
... | 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 VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC... |
You are given array a with n elements and the number m. Consider some subsequence of a and the value of least common multiple (LCM) of its elements. Denote LCM as l. Find any longest subsequence of a with the value l β€ m.
A subsequence of a is an array we can get by erasing some elements of a. It is allowed to erase z... | from sys import stdin
input = stdin.buffer.readline
n, m = map(int, input().split())
cnt = [0] * (m + 1)
(*b,) = map(int, input().split())
for i in b:
if i <= m:
cnt[i] += 1
a = [0] * (m + 1)
for i in range(1, m + 1):
for j in range(i, m + 1, i):
a[j] += cnt[i]
mx = idx = 0
for i in range(1, m ... | ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_C... |
You are given array a with n elements and the number m. Consider some subsequence of a and the value of least common multiple (LCM) of its elements. Denote LCM as l. Find any longest subsequence of a with the value l β€ m.
A subsequence of a is an array we can get by erasing some elements of a. It is allowed to erase z... | import sys
n, m = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B, C = [0] * (m + 1), [0] * (m + 1)
for a in A:
if a <= m:
B[a] += 1
for i in range(2, m + 1):
for j in range(i, m + 1, i):
C[j] += B[i]
k, l = 1, 0
for i in range(2, m + 1):
if C[i] > l:
l = C... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR... |
You are given array a with n elements and the number m. Consider some subsequence of a and the value of least common multiple (LCM) of its elements. Denote LCM as l. Find any longest subsequence of a with the value l β€ m.
A subsequence of a is an array we can get by erasing some elements of a. It is allowed to erase z... | import sys
n, m = map(int, sys.stdin.buffer.readline().decode("utf-8").split())
a = list(map(int, sys.stdin.buffer.readline().decode("utf-8").split()))
dp = [0] * (m + 1)
for x in a:
if x <= m:
dp[x] += 1
for i in range(m, 0, -1):
for j in range(2, m + 1):
if i * j > m:
break
... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER ... |
Little C loves number Β«3Β» very much. He loves all things about it.
Now he is playing a game on a chessboard of size n Γ m. The cell in the x-th row and in the y-th column is called (x,y). Initially, The chessboard is empty. Each time, he places two chessmen on two different empty cells, the Manhattan distance between ... | n, m = map(int, input().split())
q = min(n, m)
w = max(n, m)
if q == 1 and w <= 3 or q == 2 == w:
print("0")
elif q == 1 and w == 4:
print("2")
elif q == 1 and w == 5:
print("4")
elif q == 1 and w == 6:
print("6")
elif q == 2 and w == 3:
print("4")
elif q == 1:
r = w // 6
if w % 6 == 0:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR... |
Little C loves number Β«3Β» very much. He loves all things about it.
Now he is playing a game on a chessboard of size n Γ m. The cell in the x-th row and in the y-th column is called (x,y). Initially, The chessboard is empty. Each time, he places two chessmen on two different empty cells, the Manhattan distance between ... | n, m = map(int, input().split(" "))
if n == 1 or m == 1:
print(n * m // 6 * 6 + (n * m % 6 > 3) * (n * m % 6 % 3 * 2))
elif n * m < 6:
print(0)
elif n * m == 6:
print(4)
elif n * m == 14:
print(12)
else:
print(n * m - n * m % 2) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP V... |
Little C loves number Β«3Β» very much. He loves all things about it.
Now he is playing a game on a chessboard of size n Γ m. The cell in the x-th row and in the y-th column is called (x,y). Initially, The chessboard is empty. Each time, he places two chessmen on two different empty cells, the Manhattan distance between ... | n, m = map(int, input().split())
if n >= 4 and m >= 4:
print(n * m - n * m % 2)
elif min(n, m) == 1:
if max(n, m) % 6 == 5:
print(max(n, m) // 6 * 6 + 4)
elif max(n, m) % 6 == 4:
print(max(n, m) // 6 * 6 + 2)
else:
print(max(n, m) // 6 * 6)
elif min(n, m) == 2 and max(n, m) == 7:... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER NUMBER IF BIN_... |
Little C loves number Β«3Β» very much. He loves all things about it.
Now he is playing a game on a chessboard of size n Γ m. The cell in the x-th row and in the y-th column is called (x,y). Initially, The chessboard is empty. Each time, he places two chessmen on two different empty cells, the Manhattan distance between ... | class Solution(object):
def run(self):
n, m = [int(x) for x in input().split()]
if n > m:
n, m = m, n
res = n * m // 2
if n == 1 and (m + 1) % 6 // 3:
res -= 1
elif n == 2:
if m == 2:
res = 0
elif m == 3:
... | CLASS_DEF VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER VAR NUMBER IF VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER... |
Little C loves number Β«3Β» very much. He loves all things about it.
Now he is playing a game on a chessboard of size n Γ m. The cell in the x-th row and in the y-th column is called (x,y). Initially, The chessboard is empty. Each time, he places two chessmen on two different empty cells, the Manhattan distance between ... | N, M = map(int, input().split())
l = [0, 1, 2, 3, 2, 1]
res = float("inf")
for n, m in ((N, M), (M, N)):
if l[n % 6] == 0:
print(n * m)
exit()
elif l[n % 6] == 1:
tmp = l[m % 6]
res = min(res, tmp)
elif l[n % 6] == 2:
if m >= 4 and m != 7:
print(n * m)
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR VAR VAR VAR VAR VAR IF VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NU... |
Little C loves number Β«3Β» very much. He loves all things about it.
Now he is playing a game on a chessboard of size n Γ m. The cell in the x-th row and in the y-th column is called (x,y). Initially, The chessboard is empty. Each time, he places two chessmen on two different empty cells, the Manhattan distance between ... | n, m = map(int, input().split())
if n > m:
n, m = m, n
if n == 1:
ans = m // 6 * 6 + 2 * max(m % 6 - 3, 0)
print(ans)
elif n == 2:
if m == 2:
print(0)
elif m == 3:
print(4)
elif m == 7:
print(12)
else:
print(n * m)
else:
ans = n * m // 2 * 2
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FU... |
Little C loves number Β«3Β» very much. He loves all things about it.
Now he is playing a game on a chessboard of size n Γ m. The cell in the x-th row and in the y-th column is called (x,y). Initially, The chessboard is empty. Each time, he places two chessmen on two different empty cells, the Manhattan distance between ... | n, m = map(int, input().split())
if n < m:
n, m = m, n
ans = 0
d = {(0): 0, (1): 1, (2): 2, (3): 3, (4): 2, (5): 1}
if m == 1:
ans = d[n % 6]
elif m == 2:
if n == 3:
ans = 2
elif n == 2:
ans = 4
elif n == 7:
ans = 2
else:
ans = n * m % 2
print(n * m - ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSI... |
Little C loves number Β«3Β» very much. He loves all things about it.
Now he is playing a game on a chessboard of size n Γ m. The cell in the x-th row and in the y-th column is called (x,y). Initially, The chessboard is empty. Each time, he places two chessmen on two different empty cells, the Manhattan distance between ... | n, m = map(int, input().strip().split())
f = min(n, m)
f1 = max(n, m)
def s(g):
if g % 6 == 1 or g % 6 == 5:
return 1
if g % 6 == 2 or g % 6 == 4:
return 2
if g % 6 == 0:
return 0
if g % 6 == 3:
return 3
if f == 1:
f3 = s(f1)
print(n * m - f3)
exit(0)
if f... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_DEF IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN NUMBER IF... |
Little C loves number Β«3Β» very much. He loves all things about it.
Now he is playing a game on a chessboard of size n Γ m. The cell in the x-th row and in the y-th column is called (x,y). Initially, The chessboard is empty. Each time, he places two chessmen on two different empty cells, the Manhattan distance between ... | a, b = map(int, input().split())
a, b = min(a, b), max(a, b)
if a == 1:
c = b % 6
if c == 4:
print(b // 6 * 6 + 2)
elif c == 5:
print(b // 6 * 6 + 4)
else:
print(b // 6 * 6)
elif a == 2:
if b <= 2:
print(0)
elif b == 3 or b == 7:
print(a * b - 2)
else:... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER EXP... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | n = int(input())
a = list(map(int, input().split()))
if n & 1:
n -= 1
ans = 0
for i in range(0, n, 2):
now = low = a[i] - a[i + 1]
ans += min(a[i], a[i + 1])
for j in range(i + 2, n, 2):
now += a[j] - a[j + 1]
if now >= 0:
tmp = a[i] - now
ans += max(min(low - now... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BI... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | n = int(input())
c = list(map(int, input().split()))
ans = 0
for i in range(n):
if i % 2:
continue
min_depth = 0
bal = 0
for j in range(i + 1, n):
if (j - i) % 2:
ans += max(0, min(c[i], c[j] - bal) - max(-min_depth, 1 - bal) + 1)
bal -= c[j]
min_depth... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP BIN_O... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | import sys
input = sys.stdin.readline
def main():
t = 1
class RangeQuery:
def __init__(self, data, func=min):
self.func = func
self._data = _data = [list(data)]
i, n = 1, len(_data[0])
while 2 * i <= n:
prev = _data[-1]
... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER CLASS_DEF FUNC_DEF VAR ASSIGN VAR VAR ASSIGN VAR VAR LIST FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER WHILE BIN_OP NUMBER VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BI... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | n = int(input())
a = [*map(int, input().split())]
t = 0
for l in range(0, n, 2):
mn = 0
c = 0
for r in range(l + 1, n, 2):
if r - l > 1:
mn = min(mn, c - a[r - 2])
c += a[r - 1] - a[r - 2]
t += max(-1, min(a[l] + mn, a[r] + mn - c)) + (r - l > 1)
print(t) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR BIN_OP VA... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | n = int(input())
a = list(map(int, input().split()))
stack = []
ans = 0
for i, c in enumerate(a):
if i % 2:
while c and stack:
if stack[-1] < 0:
stack.pop()
else:
m = min(stack[-1], c)
c -= m
ans += m
if ... | 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 NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER WHILE VAR VAR IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR VAR VAR IF VAR NUMBER VAR E... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | import sys
ints = (int(x) for x in sys.stdin.read().split())
sys.setrecursionlimit(3000)
class Stack(list):
ans = 0
lzeros = 0
zeros = []
def save(self, n, k):
self.ans += n + k * (k - 1) // 2
def read(self, seq):
it = iter(seq)
for a, b in zip(it, it):
self.... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER CLASS_DEF VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FUNC_DEF VAR BIN_OP VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EX... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | import sys
def il():
return list(map(int, sys.stdin.readline().strip().split()))
def ii():
return int(sys.stdin.readline().strip())
def imi():
return map(int, sys.stdin.readline().strip().split())
n = ii()
li = il()
s = 0
for i in range(0, n, 2):
x = 0
a = li[i]
ma = 1
for j in range... | IMPORT FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER A... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | def sol():
n = int(input())
arr = [int(x) for x in input().split()]
ans = 0
for pocz in range(0, n, 2):
nasze = arr[pocz]
reszta = 0
skonczone = 0
wyn = 0
for i in range(pocz, n):
if not i % 2:
if i != pocz:
reszta +... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR ASSIGN VAR... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | import sys
input = sys.stdin.readline
n = int(input())
c = [0] + list(map(int, input().split()))
s = [0] * (n + 1)
for i in range(1, n + 1):
s[i] = s[i - 1]
if i % 2 == 1:
s[i] += c[i]
else:
s[i] -= c[i]
ans = 0
for l in range(0, n):
mn = s[l + 1]
for r in range(l + 1, n):
i... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR V... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | n = int(input())
q = dict()
ans = 0
a = list(map(int, input().split()))
for i in range(1, n, 2):
cnt = a[i]
max_cnt = a[i]
for j in range(i + 1, n):
if j % 2 == 0:
cnt -= a[j]
q[i, j] = [cnt, max_cnt]
else:
cnt += a[j]
max_cnt = max(max_cnt, cn... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR ASSIGN VA... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | def process(A):
n = len(A)
answer = 0
for i in range(0, n, 2):
my_upper = A[i]
my_lower = -1 * float("inf")
my_sum = 0
for j in range(i + 1, n):
if j % 2 == 0:
my_sum -= A[j]
else:
this_upper = min(my_upper, A[j] + my_su... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR ASSIGN VA... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | n = int(input())
a = list(map(int, input().split()))
ans = 0
stk = [[a[0], 0]]
i = 1
fi = [-1] * n
while i < n:
if i % 2 == 0:
stk.append([a[i], i])
else:
while a[i] > 0 and len(stk):
if a[i] < stk[-1][0]:
ans += a[i]
stk[-1][0] -= a[i]
... | 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 LIST VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR LIST VAR VAR VAR WHILE VAR VAR NUMBER FUNC_C... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | n = int(input())
s = list(map(int, input().split()))
h = 0
sign = 1
low = high = 0
t = {}
count = 0
for x in s:
h += sign * x
if sign == 1:
high = h
else:
count += x
for hh in t:
if hh >= h and hh <= h + x:
count += t[hh]
elif hh > h:
... | 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 NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR VAR VAR VAR FOR VAR VAR IF VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR ... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | n = int(input())
arr = [int(x) for x in input().split()]
ans = [int(0) for x in range(n + 1)]
tempans = [int(0) for x in range(n + 1)]
arr.insert(0, 0)
for i in range(2, n + 1, 2):
if arr[i] < arr[i - 1]:
ans[i] += arr[i]
else:
ans[i] += arr[i - 1]
temp = arr[i]
ans[i] += tempans... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER I... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | n = int(input())
c = list(map(int, input().split()))
ans = 0
for j in range(0, n, 2):
boo = c[j]
remain = 0
for i in range(j, n):
if i % 2 == 0:
remain += c[i]
else:
remain -= c[i]
if remain <= boo:
ans += boo - max(remain, 0)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR VAR VAR VAR IF VAR VAR VAR BIN_OP VAR FUNC_CALL V... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | n = int(input())
c = [int(x) for x in input().split()]
ans = 0
for i in range(0, n, 2):
dt = 0
s = 0
for j in range(i + 1, n):
if j & 1:
L = max(1, -s)
R = c[i]
if L <= R:
L += dt
R += dt
L = max(L, 1)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR IF VAR VAR... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | from sys import stdin, stdout
ip = lambda: stdin.readline().rstrip("\r\n")
ips = lambda: ip().split()
out = lambda x, end="\n": stdout.write(str(x) + end)
n = int(ip())
a = list(map(int, ips()))
ans = 0
for i in range(n):
no, nc, p = 0, 0, 0
if i & 1:
continue
x = a[i]
if i + 1 < n:
ans... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER IF... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | import sys
n = int(sys.stdin.readline())
data = list(map(int, sys.stdin.readline().split()))
ans, cur_open = 0, 0
s = [[0, 0]]
for i in range(0, n, 2):
if i + 1 >= n:
continue
open_bracket = data[i]
close_bracket = data[i + 1]
cur_open += open_bracket - close_bracket
ans += min(close_bracke... | IMPORT 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 NUMBER NUMBER ASSIGN VAR LIST LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR FUN... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | import sys
input = sys.stdin.readline
def sv(ls):
ret = 0
deep = 0
stack = []
for i in range(len(ls)):
v = ls[i]
if i % 2 == 0:
deep += v
else:
append = True
if v > deep:
append = False
v = min(v, deep)
... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR NONE WHILE VAR ASSIGN VAR VAR VAR N... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | import sys
input = lambda: sys.stdin.readline().strip()
def solve():
n = int(input())
arr = list(map(int, input().split()))
res = 0
for i in range(0, n, 2):
x = xmin = 0
for j in range(i + 1, n):
if j & 1:
l = max(1, 1 - x, -xmin)
r = min(ar... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR 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 NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR NUMBER ASSIGN VAR FUNC_CA... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | l = int(input())
s = [int(i) for i in input().split()]
p = ans = 0
st = []
for i in range(l):
if i % 2:
if p >= s[i]:
p -= s[i]
ans += s[i]
else:
ans += p
p = -1
while st and st[-1][0] > p:
pp, t = st.pop()
ans += t
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR NUMBER NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR IF VA... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | from sys import stdin, stdout
input = stdin.readline
def output(answer):
stdout.write("{}\n".format(answer))
def transfer(stack, other, flag):
if flag == 0:
while len(other) > 0:
stack.append(other.pop())
else:
while len(other) > 0:
v = other.pop()
if... | ASSIGN VAR VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL STRING VAR FUNC_DEF IF VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN V... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | def main():
res = 0
n = int(input())
a = list(map(int, input().split()))
a = [0] + a
for i in range(1, n, 2):
ans = 0
_ans = 0
for j in range(i + 1, n + 1, 2):
if a[i] < -_ans:
break
l = max(0, ans - _ans)
r = min(a[j], ans ... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER IF VAR VAR V... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | N = int(input())
cs = list(map(int, input().split()))
stack = []
p = 0
min_height = 0
height = 0
answer = 0
for c in cs:
if p == 0:
height += c
else:
new_height = height - c
while stack and stack[-1][0] > new_height:
h, cnt = stack.pop()
answer += cnt - 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR VAR WHILE VAR VAR NUMBER NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR B... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | n = int(input())
aa = list(map(int, input().split()))
ans = 0
stk = []
for i in range(n):
if not stk:
stk.append([0, 1])
if i & 1:
while aa[i] and stk:
if stk[-1][1] == 0:
stk.pop()
if stk:
now = stk.pop()
sub = min(now[0], ... | 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 FOR VAR FUNC_CALL VAR VAR IF VAR EXPR FUNC_CALL VAR LIST NUMBER NUMBER IF BIN_OP VAR NUMBER WHILE VAR VAR VAR IF VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR IF VAR ASSIGN VAR FUNC_... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | if 1:
n = int(input())
c = list(map(int, input().split()))
count = 0
open_brackets_left = 0
prev_brackets_left = []
for i, c_i in enumerate(c):
if i % 2:
count += min(c_i, open_brackets_left)
open_brackets_left -= c_i
while prev_brackets_left:
... | IF NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR VAR WHILE VAR IF VAR NUMBER NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | n = int(input().strip())
a = [int(x) for x in input().strip().split(" ")]
ans = 0
for i in range(0, n, 2):
now = 0
mn_now = a[i] - 1
for j in range(i, n):
if j & 1:
pre_now = now
now -= a[j]
ans += max(0, min(pre_now, mn_now + 1) - max(0, now))
mn_now ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR FUNC_C... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | class SegTree:
def __init__(self, init_val, ide_ele, segfunc):
self.n = len(init_val)
self.num = 2 ** (self.n - 1).bit_length()
self.ide_ele = ide_ele
self.segfunc = segfunc
self.seg = [ide_ele] * 2 * self.num
for i in range(self.n):
self.seg[i + self.num... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER FUNC_CALL BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP LIST VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR V... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | n = int(input())
u = list(map(int, input().split()))
ans = -(n // 2)
for i in range(0, n, 2):
x = u[i]
p = 0
for j in range(i + 1, n):
if j % 2:
if p > u[j]:
p -= u[j]
elif x + p < u[j]:
ans += x + 1
break
else:
... | 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 VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR VAR IF BIN_OP VAR VA... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | import sys
input = sys.stdin.readline
INF = int(1000000000.0) + 7
dx = [-1, 0, 1, 0]
dy = [0, 1, 0, -1]
def solve():
n = int(input())
data = list(map(int, input().split()))
remain = []
final = [0] * n
dp = [0] * n
for i in range(n):
now = i % 2
if now == 0:
remain.... | IMPORT ASSIGN VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER 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 LIST ASSIGN VAR BIN_OP LIST NUMBER VAR... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.