description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Consider the following algorithm, which generates a (not necessarily uniformly) random permutation of numbers $1$ through $N$: P := [1, 2, ..., N] for i in 1..N do j := rand(1, N) swap(P[i], P[j]) Here, rand(1, N) ...
n = int(input()) if n == 1: print("1") print("1") elif n == 2: print("1 2") print("2 1") elif n == 3: print("2 1 3") print("3 1 2") else: med = n // 2 print( " ".join([str(x) for x in range(2, med + 1)]), 1, " ".join([str(x) for x in range(med + 2, n + 1)]), ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR ...
Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Consider the following algorithm, which generates a (not necessarily uniformly) random permutation of numbers $1$ through $N$: P := [1, 2, ..., N] for i in 1..N do j := rand(1, N) swap(P[i], P[j]) Here, rand(1, N) ...
n = int(input()) arr = [i for i in range(0, n + 1)] for i in range(1, n): if i != n // 2: arr[i], arr[i + 1] = arr[i + 1], arr[i] for i in range(1, n + 1): print(arr[i], end=" ") print() print(n, end=" ") for i in range(1, n): print(i, end=" ")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VA...
Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Consider the following algorithm, which generates a (not necessarily uniformly) random permutation of numbers $1$ through $N$: P := [1, 2, ..., N] for i in 1..N do j := rand(1, N) swap(P[i], P[j]) Here, rand(1, N) ...
n = int(input()) middle = n / 2 if middle * 10 % 10 != 0: middle = int(middle) + 1 middle = int(middle) for i in range(1, middle): print(i + 1, end=" ") print(1, end=" ") for i in range(middle + 2, n + 1): print(i, end=" ") print(middle + 1, end="\n") print(n, end=" ") for i in range(n - 1): print(i + 1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER STRING FOR VAR FUNC_CALL VAR BIN_OP...
You have a string of decimal digits s. Let's define b_{ij} = s_{i}·s_{j}. Find in matrix b the number of such rectangles that the sum b_{ij} for all cells (i, j) that are the elements of the rectangle equals a in each rectangle. A rectangle in a matrix is a group of four integers (x, y, z, t) (x ≤ y, z ≤ t). The eleme...
a = int(input()) b = [int(i) for i in input()] n = len(b) c = [0] * (sum(b) + 1) d = [0] e = 0 for i in range(n): e += b[i] d.append(e) for i in range(n): for j in range(i, n): c[d[j + 1] - d[i]] += 1 if a == 0: print(2 * c[0] * sum(c) - c[0] ** 2) else: f = 0 c1 = len(c) for i in ra...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CA...
You have a string of decimal digits s. Let's define b_{ij} = s_{i}·s_{j}. Find in matrix b the number of such rectangles that the sum b_{ij} for all cells (i, j) that are the elements of the rectangle equals a in each rectangle. A rectangle in a matrix is a group of four integers (x, y, z, t) (x ≤ y, z ≤ t). The eleme...
sm = [0] * 40000 n = int(input()) s = input() l = len(s) for i in range(l): ss = 0 for j in range(i, l): ss += int(s[j]) sm[ss] += 1 if n == 0: ans = 0 for i in range(1, 40000): ans += sm[0] * sm[i] * 2 ans += sm[0] * sm[0] print(ans) else: ans = 0 u = int(n**0.5)...
ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER VAR BIN...
You have a string of decimal digits s. Let's define b_{ij} = s_{i}·s_{j}. Find in matrix b the number of such rectangles that the sum b_{ij} for all cells (i, j) that are the elements of the rectangle equals a in each rectangle. A rectangle in a matrix is a group of four integers (x, y, z, t) (x ≤ y, z ≤ t). The eleme...
def divisors(x): def f(y, q): t = -len(r) while not y % q: y //= q for i in range(t, 0): r.append(r[t] * q) return y r, p = [1], 7 x = f(f(f(x, 2), 3), 5) while x >= p * p: for s in (4, 2, 4, 2, 4, 6, 2, 6): if not x %...
FUNC_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR WHILE BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR RETURN VAR ASSIGN VAR VAR LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER NUMBER WHILE VAR BIN_OP VAR VAR FOR VAR NUMBER NUMBER NUM...
You have a string of decimal digits s. Let's define b_{ij} = s_{i}·s_{j}. Find in matrix b the number of such rectangles that the sum b_{ij} for all cells (i, j) that are the elements of the rectangle equals a in each rectangle. A rectangle in a matrix is a group of four integers (x, y, z, t) (x ≤ y, z ≤ t). The eleme...
def f(t, k): i, j = 0, 1 s, d = 0, t[0] n = len(t) while j <= n: if d > k: d -= t[i] i += 1 elif d == k: if t[i] and (j == n or t[j]): s += 1 else: a, b = i - 1, j - 1 while j < n and t[j] == ...
FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR IF VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR NUMBER VAR NUMBER WHILE VAR VAR NUMBER VAR NUMBER ...
You have a string of decimal digits s. Let's define b_{ij} = s_{i}·s_{j}. Find in matrix b the number of such rectangles that the sum b_{ij} for all cells (i, j) that are the elements of the rectangle equals a in each rectangle. A rectangle in a matrix is a group of four integers (x, y, z, t) (x ≤ y, z ≤ t). The eleme...
a = int(input()) s = input() d = {} for i in range(len(s)): for j in range(i, len(s)): if j == i: t = int(s[j]) else: t += int(s[j]) d[t] = d.get(t, 0) + 1 if a == 0: if 0 in d: cnt_pairs = len(s) * (len(s) + 1) // 2 print(d[0] * cnt_pairs + d[0] *...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER IF VAR NUMBER IF NUMBER VAR ASSI...
You have a string of decimal digits s. Let's define b_{ij} = s_{i}·s_{j}. Find in matrix b the number of such rectangles that the sum b_{ij} for all cells (i, j) that are the elements of the rectangle equals a in each rectangle. A rectangle in a matrix is a group of four integers (x, y, z, t) (x ≤ y, z ≤ t). The eleme...
a = int(input()) s = input() di = {} for i in range(len(s)): total = 0 for j in range(i, len(s)): total += int(s[j]) di[total] = 1 if total not in di else di[total] + 1 ans = 0 if a == 0: ans = 0 if 0 in di: ans += di[0] * di[0] for each in di: if not each: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF NUMBER ...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
def consc_count(stri): res = [] i = 0 while i < len(stri): if stri[i] == "0": c = 1 j = i + 1 while j < len(stri): if stri[i] == stri[j]: c += 1 else: break j += 1 ...
FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VA...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
for t in range(int(input())): l, h = map(int, input().split()) total = input() ans = "NO" l1 = total.split("1") l2 = [] for i in l1: l2.append(len(i)) for i in l2: if i < h: if i > h // 2: h = 2 * (h - i) else: continue ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER ...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
for _ in range(int(input())): l, h = map(int, input().split()) s = input().split("1")[:l] a = False for i in s: if i != "": if len(i) >= h: a = True break elif len(i) > h // 2: h = 2 * (h - len(i)) if a == True: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING IF FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR FUNC_...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
for _ in range(int(input())): l, h = map(int, input().split()) s = input() ai = [] c = flag = 0 for i in range(l): if s[i] == "1": ai.append(c) c = 0 else: c = c + 1 ai.append(c) ai.sort(reverse=True) for j in range(len(ai)): if...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CAL...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
T = int(input()) for t in range(T): l, h = map(int, input().split()) a = list(input()) for i in range(len(a)): a[i] = int(a[i]) s = [] c = 0 for i in range(len(a)): if a[i] == 0: c += 1 elif i == 0: pass elif a[i - 1] == 0: s.ap...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR V...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
t = int(input()) for i in range(t): a, b = map(int, input().split()) x = input() lt = [] count = 0 for i in x: if i == "1": if count != 0: lt.append(count) count = 0 else: count += 1 if count != 0: lt.append(count) l...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
from itertools import groupby T = int(input()) for i in range(T): n, h = tuple(map(int, input().split())) s = input() cluster = groupby(s) st = [] for key, value in cluster: st.append((key, len(list(value)))) ok = False for i in st: key, value = i if key == "1": ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR VAR EXPR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VA...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
for _ in range(int(input())): l, h = map(int, input().split()) s = input() j = 0 x = 0 s1 = s.split("1") if s.count("0") >= h: while j < len(s1): x = len(s1[j]) if x != 0: if x >= h // 2: h = 2 * (h - x) if h <= 0: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR STRING VAR WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER IF VAR BIN_OP VAR...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
try: t = int(input()) for i in range(t): outcomes = ["NO", "YES"] n, h = map(int, input().split()) flag = False dayString = input().split("1") for i in dayString: if len(i) < h: h = min(h, 2 * (h - len(i))) else: fla...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST STRING STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP NUMBER BIN_OP VAR FUNC_CALL VAR VAR...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
def cons_count(stri): n_s = [] i = 0 while i < len(stri): if stri[i] == "0": c = 1 j = i + 1 while j < len(stri): if stri[i] == stri[j]: c += 1 else: break j += 1 n...
FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE ...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
def binarySearch(arr, l, r, x): ans = -1 while l <= r: mid = l + (r - l) // 2 if arr[mid] >= x: ans = mid r = mid - 1 else: l = mid + 1 return ans def continous_zero(s): lst = [] c = 0 for i in range(len(s) - 1): if s[i] == "0...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR STRING IF VAR VAR VAR...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
t = int(input()) for i in range(t): l, h = map(int, input().split()) s = input() flag = False zeroes = s.split("1") count = [] for e in zeroes: count.append(len(e)) for val in count: if 2 * (h - val) <= h: h = 2 * (h - val) if h <= 0: flag = Tr...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR IF BIN_OP NUMBER BIN_OP VAR VAR VAR ASSIGN VAR...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
T = int(input()) while T != 0: l, h = map(int, input().split()) s = input() arr = [] count = 0 for i in s: if i == "0": count += 1 else: arr.append(count) if count == 0 and len(arr) != 0: arr.pop() count = 0 if count...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBE...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
for tc in range(int(input())): l, h = map(int, input().split()) s = input().split("1") s = [(len(s[i]), -i) for i in range(len(s))] s.sort() i0 = -1 while len(s) > 0 and h > 0: x, i = s.pop() while len(s) > 0 and -i < i0: x, i = s.pop() h = 2 * (h - x) ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
from sys import stdin for __ in range(int(stdin.readline())): l, h = map(int, stdin.readline().split()) s = stdin.readline().strip() cnt = 0 for i in s: if i == "0": cnt += 1 else: if 2 * (h - cnt) < h: h = 2 * (h - cnt) cnt = 0 if...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF BIN_OP NUMBER BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR VAR ASSIGN VAR NUMBER IF BIN_OP NUMBER BIN_OP VAR V...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
t = int(input()) while t > 0: l, h = map(int, input().split()) s = input() units = [] c = 0 for i in range(l): if s[i] == "0": c += 1 else: units.append(c) c = 0 units.append(c) units = [i for i in units if i != 0] for i in range(len(un...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR NU...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
for _ in range(int(input())): L, H = map(int, input().split()) S = input() oc = 0 z = [] for ele in S: if ele == "0": oc += 1 elif oc != 0: z.append(oc) oc = 0 if oc != 0: z.append(oc) for ele in z: if ele > H / 2: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR IF VAR BIN_OP...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
t = int(input()) for i in range(0, t): l, h = map(int, input().split()) s = list(input()) aa = [] cau = False a = 0 for j in range(0, len(s)): if s[j] == "0" and not cau: cau = True a = 1 elif s[j] == "0" and cau: a += 1 if s[j] == "1":...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR ASSIGN VAR NUMBER ASSIGN VAR NU...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
for _ in range(int(input())): l, h = map(int, input().split()) a = list(input()) i = 1 b = [] s = 0 if "0" not in a: print("NO") continue if a[0] == "0": s = 1 while i < l: if a[i] == "0" and a[i - 1] == "0": s += 1 elif a[i] == "0": ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER STRING ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR STRING VAR BIN_OP ...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
for q in range(int(input())): l, h = map(int, input().split()) s = input() c = 0 for i in s: if int(i) == 0: c += 1 else: if 2 * c > h: h = 2 * (h - c) c = 0 if h - c <= 0: break if h - c <= 0: print("YES...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER IF BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER IF BIN_OP V...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
t = int(input()) for _ in range(t): n, h = map(int, input().split()) s = input() arr = [] count = 0 for i in range(n): if s[i] == "0": count = count + 1 else: if count != 0: arr.append(count) count = 0 if count != 0: arr...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMB...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
t = int(input()) for _ in range(t): L, h = map(int, input().split()) s = input() l = [] a = [] c = 0 for i in range(L): if s[i] == "0" and i != L - 1: c = c + 1 elif s[i] == "0" and i == L - 1: c = c + 1 a.append(c) elif i == L - 1 or s...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR BIN_OP...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
for _ in range(int(input())): l, h = map(int, input().split()) s = input() s = s.split("1") l = [len(i) for i in s if len(i) != 0] ans = "NO" for i in l: if i >= h: ans = "YES" break elif i > h // 2: h = 2 * (h - i) else: co...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING FOR VAR VAR IF VAR VAR ASSIGN VAR STRING IF VAR BIN_OP VAR NUMBER ASSIGN VAR...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
for _ in range(int(input())): l, h = map(int, input().split()) s = input()[:l] lst = s.split("1") flag = True zeros = [] for i in lst: zeros.append(len(i)) for i in zeros: if i >= h: print("YES") flag = False break elif i > h // 2: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
for _ in range(int(input())): _, h = map(int, input().split()) c = input() cnt = 0 for i in c: if i == "0": cnt += 1 if i == "1" and cnt: rh = 2 * (h - cnt) h = rh if rh < h else h cnt = 0 if cnt >= h or h <= 0: h = 0 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN V...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
for _ in range(int(input())): l, h = map(int, input().split()) s = input() a = s.split("1") a = " ".join(a).split() flag = 0 if l == s.count("0"): print("YES") elif len(a) == 0: print("NO") else: for i in a: b = 2 * (h - len(i)) if b <= h: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL STRING VAR ASSIGN VAR NUMBER IF VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
for i in range(int(input())): flag = False l, h = [int(i) for i in input().split()] s = input() s = s.split("1") f = [] s = sorted(s, reverse=True) for i in s: f.append(len(i)) if 0 in f: f.remove(0) if f != None: for j in f: if j >= h: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF NUMBER VAR EXPR FUNC_CALL VAR ...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
for h in range(int(input())): n, k = [int(x) for x in input().split()] string = [int(x) for x in input()] zeroes = [] index = 0 for i in range(len(string)): j = i if j >= index: while string[j] == 0: j += 1 if j == len(string): ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR IF VAR VAR WHILE VAR VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR ASSIG...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
for _ in range(int(input())): l, h = list(map(int, input().split())) s = input().split("1") a = [] for i in s: a += [len(i)] a.sort(reverse=True) for i in a: if i == 0 or h <= 0: break h = (h - i) * 2 if h > 0: print("NO") else: print("...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR VAR VAR LIST FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
try: for _ in range(int(input())): A = [int(x) for x in input().split()] s = input() arr = [] i, p = 0, 0 while i < len(s): if s[i] == "0": p += 1 if s[i] == "1": if p != 0: arr.append(p) ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER IF...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
t = int(input()) for _ in range(0, t): inputs = [int(num) for num in input().split()] l = inputs[0] h = inputs[1] s = input() streak = 0 flag = 0 for i in range(0, len(s)): if s[i] == "0": streak += 1 elif s[i] != "0": if streak > h // 2: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
T = int(input()) l2 = [] for i in range(1, T + 1): L, H = map(int, input().split()) S = input()[:L] count = 0 l = [] for i in range(L): if S[i] == "0": count += 1 elif S[i] == "1": if count != 0: l.append(count) count = 0 if...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING IF VAR NUMBER EXPR FUNC_C...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
t = int(input()) for i in range(t): l, h = map(int, input().split()) s = input() l1 = s.split("1") l2 = [] for j in l1: if j != "": l2.append(len(j)) if l2 == []: print("NO") else: for k in l2: if k >= h: print("YES") ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR LIST EXPR FUNC_CALL VAR STRING FOR VAR VAR IF VAR VAR E...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
t = int(input()) for i in range(0, t): p = input().split(" ") l = int(p[0]) h = int(p[1]) s = input() s = s.split("1") ml = [] for j in s: if j != "": ml.append(j) if len(ml) == 0: print("NO") else: d = dict() for var in ml: d[v...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR IF FUNC_CALL...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
T = int(input()) for _ in range(T): l, h = map(int, input().split()) s = input() cont_free = [] for i in s: if len(cont_free) == 0: cont_free.append([i, 1]) elif cont_free[-1][0] == i: cont_free[-1][1] += 1 else: cont_free.append([i, 1]) fo...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR LIST VAR NUMBER IF VAR NUMBER NUMBER VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR LIST VAR NUMB...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
for _ in range(int(input())): a, b = map(int, input().split()) s = input() l = [] i = 0 while i < a: if s[i] == "0": n = 0 while i < a and s[i] == "0": n += 1 i += 1 l.append(n) i += 1 for i in l: if 2 * ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR STRING ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER FOR VAR VAR IF BIN_...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
t = int(input()) for _ in range(t): l, h = map(int, input().split()) L = list(input()) M = [0] a = 0 for i in range(l): if L[i] == "0": a += 1 elif a == 0: pass else: M.append(a) a = 0 if L[-1] == "0": M.append(a) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR N...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
def solve(l, h, s): t = [] z = 0 le = 0 for i in range(l): if s[i] == "0": z += 1 else: if z > 0: t.append(z) le += 1 z = 0 if z > 0: t.append(z) le += 1 t.sort() while le > 0: temp = ...
FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
def compute(S, L, H): temp = S.split("1") zeroes = [] for each in temp: if len(each) > 0: zeroes.append(len(each)) for zero in zeroes: if 2 * (H - zero) < H: H = 2 * (H - zero) if H <= 0: break return H <= 0 t = int(input()) for i in rang...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR IF BIN_OP NUMBER BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR VAR IF VAR NUMBER RETURN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR A...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
t = int(input()) while t: l, h = [int(x) for x in input().split()] s = input() s += "1" sum = 0 a = [] for i in s: if i == "0": sum += 1 elif sum > 0: a.append(sum) sum = 0 for i in a: if i >= h: print("YES") ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
for _ in range(int(input())): l, h = map(int, input().split()) string = input() dp = [0] * l dp[0] = int(not int(string[0])) for i in range(1, l): a = string[i] b = string[i - 1] if a == "0" and b == "0": dp[i] = dp[i - 1] + 1 elif a == "1" and b == "1": ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR STRIN...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
try: for _ in range(int(input())): total, s = [int(x) for x in input().split()] if total < s: print("NO") continue if s == 0: print("YES") continue val = input() if total == s: if "1" in val: print("N...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR IF VAR VAR IF STRING VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR L...
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well. Chef has been studying the human sleep cycle for years. He divides a day into $L$ units of time (numbered $1$ through $L$). Chef's research shows that his body requires spending only $H$ continuous units of time per day on sleep — then...
def get_next_required_sleep(current_required_sleep, start_idle, end_idle): sleep_duration = end_idle - start_idle + 1 next_required_sleep = ( 0 if sleep_duration >= current_required_sleep else min(current_required_sleep, (current_required_sleep - sleep_duration) * 2) ) return nex...
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FOR VAR VAR FUNC_CALL...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
t = int(input()) l1 = [0] * 100000 l2 = [0] * 100000 c = 0 for i in range(0, t): n = int(input()) c = 0 l = list(map(int, input().split())) l1 = l[:] l2 = l[:] for j in range(0, n): if l[j] == l1[j]: for k in range(0, n): if l[k] != l1[j]: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR FO...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
from itertools import permutations from sys import stdin for _ in range(int(stdin.readline())): n = int(stdin.readline()) a = list(map(int, stdin.readline().split())) h = 0 b = a.copy() if n <= 4: b = a.copy() for p in list(permutations(a)): temph = 0 for i 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 FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VA...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
for _ in range(int(input())): ans = [] n = int(input()) l = [int(x) for x in input().rstrip().split()] if n == 1: print(0) print(l[0]) continue elif n == 2: if l[0] == l[1]: print(0) ans = l else: print(2) ans = ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VA...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) d = {} b = [0] * n for i in range(n): d[a[i]] = d.get(a[i], []) + [i] if n == 2: b[0] = a[1] b[1] = a[0] elif n == 3: p = a[0] b[0] = a[1] b[1] = a[2] b[...
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 DICT ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR LIST LIST VAR IF VAR NUMBER ASSIGN VAR N...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
for TestCase in range(int(input())): Size = int(input()) L = list(map(int, input().split())) LCopy = list(L) e = [] if Size == 1: print(0) print(*L) else: for i in range(Size): L[i] = str(LCopy[i - 1]) if str(L[i]) == str(LCopy[i]): ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR V...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
for _ in range(int(input())): no = input() no = int(no) arr = map(int, input().split()) arr = list(arr) st = 0 if no == 1 and st == 0: print(no - 1) ansarr = [] ansarr.append(arr[0]) print(*ansarr) st = 1 elif no == 2 and st == 0: if arr[1] == ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR NUMBER EXPR FUN...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
t = int(input()) while t: t -= 1 n = int(input()) a = list(map(int, input().split())) if n == 1: print(0) print(*a) elif n == 2: if a[0] == a[1]: print(0) print(*a) else: print(n) print(*a[::-1]) elif n == 3: ...
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 VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR EXP...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
t = int(input()) for test in range(t): n = int(input()) arr = list(map(int, input().split())) indices = [] sortArr = [] hamDist = 0 for i in sorted(enumerate(arr), key=lambda x: x[1]): indices.append(i[0]) sortArr.append(i[1]) pointer = 0 i = 0 while pointer < 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 LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
def count(a, b, n): c = 0 for i in range(n): if a[i] != b[i]: c += 1 return c t = int(input()) for e in range(t): n = int(input()) a = list(map(int, input().split())) if n == 1: print(0) print(a[0]) continue dic = dict() s, d = [], [] for...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER RETURN 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 IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL ...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
test = int(input()) while test > 0: n = int(input()) new = [(0) for i in range(n)] array = [int(a) for a in input().split()] i = 0 if n == 1: print(0) print(array[0]) test = test - 1 continue while i < n: if array[i] == array[(i + 1) % n]: brea...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR V...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
t = int(input()) for i in range(t): n = int(input()) l = list(map(int, input().split())) a = [] b = [] for j in range(n): a.append([l[j], j]) b.append(l[j]) a.sort() b.sort(reverse=True) f = False for k in range(n): if b[k] == a[k][0]: if f == Fals...
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 FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
def swap(a, ind): a[ind], a[ind - 2] = a[ind - 2], a[ind] a[ind - 1], a[ind - 3] = a[ind - 3], a[ind - 1] t = int(input()) for _ in range(t): hd = 0 n = int(input()) ar = list(map(int, input().split())) i = n - 1 if n == 1: print(0) print(*ar) elif n == 2: if ar...
FUNC_DEF ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FU...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
t = int(input().strip()) pos = {} d = {} arr = [] swap = [] def swap1(x, y): arr[pos[x][0]], arr[pos[y][0]] = arr[pos[y][0]], arr[pos[x][0]] arr[pos[x][1]], arr[pos[y][1]] = arr[pos[y][1]], arr[pos[x][1]] swap[pos[x][0]] = 1 swap[pos[y][0]] = 1 swap[pos[x][1]] = 1 swap[pos[y][1]] = 1 def swa...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR LIST ASSIGN VAR LIST FUNC_DEF ASSIGN VAR VAR VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
t = int(input()) while t: n = int(input()) ct = 0 has = [] has1 = [] has2 = [] has3 = [] b = [] a = list(map(int, input().split())) for i in range(0, n): b.append(a[i]) for i in range(0, 100010): has.append(0) has3.append(0) for i in range(0, n): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
t = int(input()) for _ in range(t): n = int(input()) st = input() s = st.split() a = [0] * n if n == 1: print(0) print(st) elif n == 2: if s[0] == s[1]: print(0) for i in s: print(i, end=" ") print() else: ...
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 ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR ...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
while True: try: t = int(input()) except EOFError: break break for i in range(t): n = int(input()) a = list(map(int, input().split())) c = set(a) hd = 0 b = [] if n == len(c): if len(a) % 2 == 0: b = a[::-1] hd = len(b) elif len...
WHILE NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR 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 LIST IF VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER AS...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
def ham(A, B, n, c): dist = 0 for i in range(n): if A[i] != B[i]: dist = dist + 1 print(dist) def shuffle(A, n): B = [None] * n T = list() T = sorted(A) flag = 0 for i in range(n): for j in range(i, n): if A[i] != T[j]: if i == j:...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR IF VAR V...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
for t in range(int(input())): n = int(input()) a = list(map(int, input().split())) b = list(a) for i in range(n): if a[i] != b[i]: continue for j in range(n): if i == j: continue if a[i] != b[j] and a[j] != b[i]: b[i], b...
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 FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
for t in range(int(input())): m = int(100000.0) n = int(input()) ar = list(map(int, input().split())) freq = [(0) for i in range(m)] idxs = [[] for i in range(m)] idx = 0 for a in ar: freq[a - 1] += 1 idxs[a - 1].append(idx) idx += 1 counts = [] for i in range...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL 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 VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP VAR NUMBER NU...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
t = int(input()) for i in range(t): n = int(input()) if n == 1: a = str(input()) print(0) print(a) else: a = [s for s in input().split()] p = set(a) if len(p) != len(a): if n == 3: b = [a[-1]] + a[:-1] print(2) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF ...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
def shift(seq, n=0): a = n % len(seq) return seq[-a:] + seq[:-a] n = int(input()) while n: n = n - 1 length = int(input()) l = [int(x) for x in input().split()] maxi = 0 ival = 0 for i in range(1, length): if maxi == length: break dp = shift(l, i) co...
FUNC_DEF NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR RETURN BIN_OP VAR VAR VAR VAR 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 VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NU...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
t = int(input()) arr_list = [] hd_list = [] for i in range(t): n = int(input()) inp_list = input().split() arr = "" hd = 0 swap = 0 if n == 1: hd_list.append(0) arr = inp_list[0] elif n == 2 and inp_list[0] == inp_list[1]: hd_list.append(0) arr = inp_list[0] +...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMB...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) f = [None] * 100001 s = [None, None] l = [None, None] cnt = 0 b = 0 for i, x in enumerate(a): if f[x] is not None: f[x] ^= 1 else: cnt += 1 if cnt ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE NUMBER ASSIGN VAR LIST NONE NONE ASSIGN VAR LIST NONE NONE ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR ...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
t = int(input()) for i in range(t): n = int(input()) s = input().split() s = [int(x) for x in s] if n == 1: print("0") print(s[0]) continue elif n == 2 and s[0] == s[1]: print("0") print(s[0], s[1]) continue elif n == 2: print("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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CA...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
T = int(input()) for P in range(T): n = int(input()) x = input().split() y = list(reversed(x)) z = y.copy() for j in range(n): if x[j] == y[j]: for i in range(n): if y[i] != y[j]: if x[i] != y[j]: b = y[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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR IF VAR VAR VAR VAR ASSI...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
t = int(input()) for i in range(t): N = int(input()) A = list(map(int, input().split())) if len(A) == 1: print(0) print(*A) elif len(A) == 2: if A.count(A[0]) == 2: print(0) print(*A) else: A[0], A[1] = A[1], A[0] print(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 VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
def ip(): return int(input()) def ipp(): return map(int, input().split()) def sar(): return list(ipp()) def pars(a): print(" ".join(list(map(str, a)))) def parl(a): print("\r".join(list(map(str, a)))) def ham(a, b): s = 0 for i in range(len(a)): if a[i] != b[i]: ...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_DEF ASS...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
def dist(a, ans): c = 0 for i in range(0, n): if a[i] == ans[i]: c += 1 return c t = int(input()) for iteration in range(0, t): n = int(input()) a = list(map(int, input().split(" "))) ans = [i for i in a] c = dist(a, ans) for i in range(0, n): if a[i] == ans...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR VAR ASSIGN VAR ...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
def h(l1, l2): x = 0 l = len(l1) for i in range(l): if l1[i] == l2[i]: x += 1 return l - x for i in range(int(input())): x = int(input()) arr = input().split() arr2 = list(arr) for i in range(len(arr)): if arr[i] == arr2[i]: for j in range(0, len...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER RETURN BIN_OP 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL V...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
tests = int(input()) results = [] for i in range(0, tests): n = int(input()) numso = input().split(" ") nums = list(numso) n = len(nums) l = 0 r = n - 1 while l < r: if nums[l] != nums[r]: nums[l], nums[r] = nums[r], nums[l] l += 1 r -= 1 e...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VA...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
test = int(input()) for _ in range(test): S = int(input()) arr = {} two = {} hd = 0 c = 1 for i in input().split(): i = int(i) if i in arr: temp = arr[i][1] arr.pop(i) two[i] = {(2): [temp, c]} else: arr[i] = {(1): c} ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR DICT NUMBER ...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
def callme(): n = int(input()) arr = list(map(int, input().split())) if n == 1: print("0") print(arr[0]) return newarr = [0] * n if len(arr) == len(set(arr)): for i in range(n): newarr[i - 1] = arr[i] print(n) print(*newarr) return ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR NUMBER RETURN ASSIGN VAR BIN_OP LIST NUMBER VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
for _ in range(int(input())): n = int(input()) a = [int(s) for s in input().split()] b = [] if n == 1: print(0) print(a[0]) elif n == 2: if a[1] == a[0]: print(0) else: print(2) print(a[1], a[0]) elif n == 3: if a[1] == a[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 VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMB...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
for _ in range(int(input())): n = int(input()) l = list(map(int, input().split())) l1 = [] l1 += l[n // 2 :] l1 += l[: n // 2] c = 0 for i in range(len(l)): if l[i] != l1[i]: c += 1 print(c) for i in l1: print(i, end=" ") print()
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER EXPR FUN...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
for i in range(int(input())): n = int(input()) l1 = [] flag = 0 f = 0 l = [int(x) for x in input().split()] if n == 1: print(0) print(*l) flag = 1 if n == 2 and n != len(set(l)) and flag == 0: print(0) print(*l) flag = 1 if n == len(set(l))...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
T = int(input()) for _testcase_ in range(T): N = int(input()) A = [int(x) for x in input().split()] if len(A) <= 3: if len(A) == 1: B = [A[0]] print(0) if len(A) == 2: if A[0] == A[1]: B = [A[1], A[0]] print(0) e...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR NUMB...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
def swap(b, i, x, n): if a[i] != b[i + x]: temp = b[i] b[i] = b[i + x] b[i + x] = temp elif x < n - 2: x += 1 swap(b, i, x, n) return b for t in range(int(input())): n = int(input()) a = [int(i) for i in input().split()] b = a[::-1] ct = 0 if n >...
FUNC_DEF IF VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR RETURN 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 VA...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
t = int(input()) while t > 0: n = int(input()) c = [0] * n b = list(map(int, input().split())) if n == 1: print(0) print(b[0]) if n == 2: if b[0] == b[1]: print(0) print(b[0], b[1]) else: print(2) print(b[1], b[0]) i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL ...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
t = int(input()) while t: t -= 1 n = int(input()) a = list(map(int, input().split())) b = a[:] i = 0 while i < n: while i < n and a[i] != b[i]: i += 1 j = i + 1 while j < n and b[j] == b[i]: j += 1 if j < n: b[i], b[j] = b[j], b...
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 VAR ASSIGN VAR NUMBER WHILE VAR VAR WHILE VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR VAR NUM...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
t = int(input()) while t > 0: n = int(input()) l = list(map(int, input().split())) if n > 3: print(n) j = 0 v = l[0:n] z = [(0) for i in range(n)] while j < n: if z[j] == 1: j += 1 continue temp = l[j] ...
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 IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR WHILE VAR VAR IF VAR VAR NUMBER VAR N...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
for t in range(int(input())): n = int(input()) a = list(map(int, input().split())) b = a[::-1] count = 0 for i, val in enumerate(b): if val == a[i]: j = (i + 1) % n while j != i: if val != b[j] and val != a[j]: b[j], b[i] = b[i], b[...
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 NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR WHILE VAR VAR IF VAR VAR VAR VAR VAR VA...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
for t in range(int(input())): n = int(input()) a = list(map(int, input().split())) f = "ncorr" if len(a) == 1: print(0) print(a[0]) continue if n == len(set(a)): print(n) print(" ".join([str(a[n - 1])] + [str(a[i]) for i in range(n - 1)])) continue ...
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 STRING IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER IF VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
for i in range(int(input())): n = int(input()) l = list(map(int, input().split())) count = 0 l_copy = l[:] k = 0 while k < n: if l[k] != l[(k + 1) % n]: l[k], l[(k + 1) % n] = l[(k + 1) % n], l[k] k = k + 2 else: l[k], l[(k + 2) % n] = l[(k + 2...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR BIN...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
for i in range(int(input())): n = int(input()) l = [int(s) for s in input().split()] if len(l) == 3: ans1 = 0 ans = l[1:] + [l[0]] for w in range(3): if ans[w] != l[w]: ans1 += 1 print(ans1) print(ans[0], ans[1], ans[2]) elif len(l) == ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR E...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
for sadadsads in range(int(input())): n = int(input()) a = list(map(lambda x: int(x), input().split())) b = [i for i in a] c = [] d = {} for i in a: d[i] = i if len(d) == n: a[n // 2], a[-1] = a[-1], a[n // 2] a = a[::-1] else: i = 0 while i < len(...
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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
def print_arr(arr): for i in arr: print(i, end=" ") print() def repl(order_2, order_1, arr): b = [] for i in order_2: b.append(i) b.append(i) for i in order_1: b.append(i) l = b[:] l.extend(b[0:2]) l = l[2:] res = [] d = {} for i in range(len...
FUNC_DEF FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
for q in range(int(input())): n = int(input()) a = [int(i) for i in input().split()] b = list(set(a)) c = [a[i] for i in range(n)] lb = len(b) flag = [(0) for i in range(n)] count = 0 count1 = 0 if n == 1: print(0) for k in a: print(k, end=" ") pri...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASS...
Read problems statements in Vietnamese . Chef likes to work with arrays a lot. Today he has an array A of length N consisting of positive integers. Chef's little brother likes to follow his elder brother, so he thought of creating an array B of length N. The little brother is too small to think of new numbers himself...
def check(x, y): count = 0 for i in range(len(x)): if x[i] != y[i]: count += 1 return count t = int(input()) for k in range(t): n = int(input()) b = [int(x) for x in input().split()] a = [b[i] for i in range(1, n)] a.append(b[0]) if n > 2: for i in range(n):...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER RETURN 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 ASSIGN VAR VAR VAR VAR FUNC_CALL VAR NUMBER VAR EXP...