description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
You are given an array a with n distinct integers. Construct an array b by permuting a such that for every non-empty subset of indices S = {x_1, x_2, ..., x_{k}} (1 ≤ x_{i} ≤ n, 0 < k < n) the sums of elements on that positions in a and b are different, i. e. $\sum_{i = 1}^{k} a_{x_{i}} \neq \sum_{i = 1}^{k} b_{x_{i}}$...
n = int(input()) j = [int(x) for x in input().split(" ")] if n == 1: print(j[0]) else: k = [[j[i], i] for i in range(n)] k.sort() o = [(0) for i in range(len(k))] for i in range(len(k)): o[k[i][1]] = str(k[(i + 1) % n][0]) print(" ".join(o))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR...
You are given an array a with n distinct integers. Construct an array b by permuting a such that for every non-empty subset of indices S = {x_1, x_2, ..., x_{k}} (1 ≤ x_{i} ≤ n, 0 < k < n) the sums of elements on that positions in a and b are different, i. e. $\sum_{i = 1}^{k} a_{x_{i}} \neq \sum_{i = 1}^{k} b_{x_{i}}$...
n = int(input()) a = list(map(int, input().split())) def solve(n, a): if n == 1: return [str(a[0])] arr = [[x, i] for i, x in enumerate(a)] arr = sorted(arr, key=lambda x: x[0]) ans = [-1] * n for [x, i], [y, j] in zip(arr[1:], arr[:-1]): ans[j] = str(x) ans[arr[-1][1]] = str(a...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN LIST FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR LIST VAR VAR LIST VAR VAR ...
You are given an array a with n distinct integers. Construct an array b by permuting a such that for every non-empty subset of indices S = {x_1, x_2, ..., x_{k}} (1 ≤ x_{i} ≤ n, 0 < k < n) the sums of elements on that positions in a and b are different, i. e. $\sum_{i = 1}^{k} a_{x_{i}} \neq \sum_{i = 1}^{k} b_{x_{i}}$...
n = int(input()) L = list(map(int, input().split())) S = sorted(L) for i in L: print(S[(S.index(i) + 1) % n], end=" ")
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 VAR EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR STRING
You are given an array a with n distinct integers. Construct an array b by permuting a such that for every non-empty subset of indices S = {x_1, x_2, ..., x_{k}} (1 ≤ x_{i} ≤ n, 0 < k < n) the sums of elements on that positions in a and b are different, i. e. $\sum_{i = 1}^{k} a_{x_{i}} \neq \sum_{i = 1}^{k} b_{x_{i}}$...
import sys input = sys.stdin.readline n = int(input()) a = list(map(int, input().split())) b = sorted(a) ans = [] for x in a: ans.append(b[b.index(x) - 1]) print(*ans)
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
You are given an array a with n distinct integers. Construct an array b by permuting a such that for every non-empty subset of indices S = {x_1, x_2, ..., x_{k}} (1 ≤ x_{i} ≤ n, 0 < k < n) the sums of elements on that positions in a and b are different, i. e. $\sum_{i = 1}^{k} a_{x_{i}} \neq \sum_{i = 1}^{k} b_{x_{i}}$...
n = int(input()) a = list(map(int, input().split())) ans = sorted(a) + [min(a)] print(" ".join([str(ans[ans.index(a[i]) + 1]) for i in range(n)]))
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 FUNC_CALL VAR VAR LIST FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR
You are given an array a with n distinct integers. Construct an array b by permuting a such that for every non-empty subset of indices S = {x_1, x_2, ..., x_{k}} (1 ≤ x_{i} ≤ n, 0 < k < n) the sums of elements on that positions in a and b are different, i. e. $\sum_{i = 1}^{k} a_{x_{i}} \neq \sum_{i = 1}^{k} b_{x_{i}}$...
n = int(input()) a = list(map(int, input().split())) ans = list() for i in range(n): ans.append(0) position = dict() for i in range(n): position[a[i]] = i a = sorted(a) ans[position[a[n - 1]]] = a[0] for i in range(n - 1): ans[position[a[i]]] = a[i + 1] for i in range(n): print(ans[i], end=" ")
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 FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMB...
You are given an array a with n distinct integers. Construct an array b by permuting a such that for every non-empty subset of indices S = {x_1, x_2, ..., x_{k}} (1 ≤ x_{i} ≤ n, 0 < k < n) the sums of elements on that positions in a and b are different, i. e. $\sum_{i = 1}^{k} a_{x_{i}} \neq \sum_{i = 1}^{k} b_{x_{i}}$...
n = int(input()) A = list(map(int, input().split())) C = [] for i, a in enumerate(A): C.append((a, i)) C.sort() B = [-1] * n for i in range(n - 1): B[C[i + 1][1]] = C[i][0] B[C[0][1]] = C[-1][0] print(*B)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER NUMBER VAR VAR ...
You are given an array [A_{1}, \ldots, A_{N}]. You want to split it into several (≥ 2) [subarrays] so that the following condition holds: Calculate the sum of elements in each subarray. Then, the AND of all these sums is nonzero, where AND denotes the bitwise AND operation. Determine if it's possible. If it's possibl...
t = int(input()) while t > 0: t -= 1 n = int(input()) ar = [int(x) for x in input().split()] f = 0 b = [[(0) for x in range(31)] for x in range(n)] for i in range(n): x = ar[i] j = 0 while x > 0: d = x % 2 x //= 2 b[i][j] = d ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER 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 VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR N...
You are given an array [A_{1}, \ldots, A_{N}]. You want to split it into several (≥ 2) [subarrays] so that the following condition holds: Calculate the sum of elements in each subarray. Then, the AND of all these sums is nonzero, where AND denotes the bitwise AND operation. Determine if it's possible. If it's possibl...
for iota in range(int(input())): n = int(input()) a = list(map(int, input().split())) odd = [] while True: if len(odd) >= 2: break if a == [0] * n: break odd = [] for i in range(n): if a[i] % 2 == 1: odd.append(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 LIST WHILE NUMBER IF FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER EXP...
You are given an array [A_{1}, \ldots, A_{N}]. You want to split it into several (≥ 2) [subarrays] so that the following condition holds: Calculate the sum of elements in each subarray. Then, the AND of all these sums is nonzero, where AND denotes the bitwise AND operation. Determine if it's possible. If it's possibl...
for _ in range(int(input())): n = int(input()) l = list(map(int, input().split())) if n == 2: if l[0] & l[1] > 0: print("YES") print(2) print(1, 1) print(2, 2) continue else: print("NO") continue c0 = 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 IF VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ...
You are given an array [A_{1}, \ldots, A_{N}]. You want to split it into several (≥ 2) [subarrays] so that the following condition holds: Calculate the sum of elements in each subarray. Then, the AND of all these sums is nonzero, where AND denotes the bitwise AND operation. Determine if it's possible. If it's possibl...
for i in range(int(input())): n = int(input()) a = list(map(int, input().split())) bit = [0] * 32 ok = False for i in a: for j in range(32): if i & 1 << j > 0: bit[j] += 1 if bit[j] > 1: ok = True if ok: print("YES")...
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 NUMBER ASSIGN VAR NUMBER FOR VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR VAR NUMBER IF VAR VAR NUM...
You are given an array [A_{1}, \ldots, A_{N}]. You want to split it into several (≥ 2) [subarrays] so that the following condition holds: Calculate the sum of elements in each subarray. Then, the AND of all these sums is nonzero, where AND denotes the bitwise AND operation. Determine if it's possible. If it's possibl...
test = int(input()) while test: n = int(input()) a = [bin(int(x)) for x in input().split()] ans = [] for i in range(-1, -31, -1): for j in range(n): if len(a[j]) - 2 >= -i and a[j][i] == "1": ans.append(j + 1) if len(ans) > 1: break else: ...
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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR VAR VAR VAR STRING EXPR FUNC_CALL...
You are given an array [A_{1}, \ldots, A_{N}]. You want to split it into several (≥ 2) [subarrays] so that the following condition holds: Calculate the sum of elements in each subarray. Then, the AND of all these sums is nonzero, where AND denotes the bitwise AND operation. Determine if it's possible. If it's possibl...
import sys input = lambda: sys.stdin.readline() T = int(input()) for _ in range(T): n = int(input()) a = list(map(int, input().split())) L = [(0) for i in range(32)] for i in a: for j in range(32): if i & 1 << j: L[j] += 1 f = False for i in range(32): ...
IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR V...
You are given an array [A_{1}, \ldots, A_{N}]. You want to split it into several (≥ 2) [subarrays] so that the following condition holds: Calculate the sum of elements in each subarray. Then, the AND of all these sums is nonzero, where AND denotes the bitwise AND operation. Determine if it's possible. If it's possibl...
def fun(n, a): if a == [0] * n: print("NO") return l = [] for i in range(n): if a[i] % 2 == 1: l.append(i) if len(l) > 1: print("YES") print(len(l)) x = 1 for i in range(len(l) - 1): print(x, l[i] + 1) x = l[i] +...
FUNC_DEF IF VAR BIN_OP LIST NUMBER VAR EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR...
You are given an array [A_{1}, \ldots, A_{N}]. You want to split it into several (≥ 2) [subarrays] so that the following condition holds: Calculate the sum of elements in each subarray. Then, the AND of all these sums is nonzero, where AND denotes the bitwise AND operation. Determine if it's possible. If it's possibl...
for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) output_arr = None for i in range(n): z = format(arr[i], "032b") arr[i] = z[::-1] res = False for j in range(32): result = [] for i in range(len(arr)): if arr[i][j] == ...
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 NONE FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VA...
You are given an array [A_{1}, \ldots, A_{N}]. You want to split it into several (≥ 2) [subarrays] so that the following condition holds: Calculate the sum of elements in each subarray. Then, the AND of all these sums is nonzero, where AND denotes the bitwise AND operation. Determine if it's possible. If it's possibl...
for _ in range(int(input())): try: n = int(input()) l = list(map(int, input().strip().split())) ind, c = -1, 0 for i in range(32): c1 = 0 for j in l: if j & 1 << i: c1 += 1 if c1 > 1: c = c1 ...
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 VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR VAR NUMBER IF VAR NUMBER ASSIGN VA...
You are given an array [A_{1}, \ldots, A_{N}]. You want to split it into several (≥ 2) [subarrays] so that the following condition holds: Calculate the sum of elements in each subarray. Then, the AND of all these sums is nonzero, where AND denotes the bitwise AND operation. Determine if it's possible. If it's possibl...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) i = 1 flag = True while i < 1000000000.0: t = 0 for j in range(n): if a[j] & i == i: t += 1 if t >= 2: flag = False print("YES") ...
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 WHILE VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBE...
You are given an array [A_{1}, \ldots, A_{N}]. You want to split it into several (≥ 2) [subarrays] so that the following condition holds: Calculate the sum of elements in each subarray. Then, the AND of all these sums is nonzero, where AND denotes the bitwise AND operation. Determine if it's possible. If it's possibl...
import sys sys.setrecursionlimit(1000000) def mi(): return map(int, input().split()) def li(): return list(mi()) def si(): return str(input()) def ni(): return int(input()) def printyes(): print("YES") def printno(): print("NO") def find(a, j): count = 0 loc = [0] for ...
IMPORT EXPR FUNC_CALL VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR STRING FUNC_DEF EXPR FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR NUMBER ...
You are given an array [A_{1}, \ldots, A_{N}]. You want to split it into several (≥ 2) [subarrays] so that the following condition holds: Calculate the sum of elements in each subarray. Then, the AND of all these sums is nonzero, where AND denotes the bitwise AND operation. Determine if it's possible. If it's possibl...
for s in [*open(0)][2::2]: l = [*map(int, s.split())] f = 1 for i in range(30): b = 1 << i ind = [] for j in range(len(l)): if l[j] & b: ind += [j] if len(ind) > 1: print("YES") print(len(ind)) ind = sorted(ind) ...
FOR VAR LIST FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR LIST VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXP...
You are given an array [A_{1}, \ldots, A_{N}]. You want to split it into several (≥ 2) [subarrays] so that the following condition holds: Calculate the sum of elements in each subarray. Then, the AND of all these sums is nonzero, where AND denotes the bitwise AND operation. Determine if it's possible. If it's possibl...
resultAns = "" for _ in range(int(input())): number = int(input()) arrayList = list(map(int, input().split())) inclusive = -1 countNumber = 0 for i in range(32): counter = 0 for j in range(number): if arrayList[j] & 1 << i != 0: counter += 1 if cou...
ASSIGN VAR STRING 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 NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR BIN_OP NUMBER VAR N...
You are given an array [A_{1}, \ldots, A_{N}]. You want to split it into several (≥ 2) [subarrays] so that the following condition holds: Calculate the sum of elements in each subarray. Then, the AND of all these sums is nonzero, where AND denotes the bitwise AND operation. Determine if it's possible. If it's possibl...
def solve(n, arr): for i in range(31): left = 0 intervals = [] for j in range(n): if arr[j] & 1 << i > 0: intervals.append([left + 1, j + 1]) left = j + 1 if len(intervals) <= 1: continue intervals[-1][1] = n bre...
FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER VAR IF VAR RETURN STRING ASSIGN VAR S...
You are given an array [A_{1}, \ldots, A_{N}]. You want to split it into several (≥ 2) [subarrays] so that the following condition holds: Calculate the sum of elements in each subarray. Then, the AND of all these sums is nonzero, where AND denotes the bitwise AND operation. Determine if it's possible. If it's possibl...
from sys import stdin input = stdin.readline for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) for i in range(31): cnt, target = 0, 1 << i v = [] for j in range(n): if a[j] & target: v.append(j + 1) if len(v) > 1: ...
ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL V...
You are given an array [A_{1}, \ldots, A_{N}]. You want to split it into several (≥ 2) [subarrays] so that the following condition holds: Calculate the sum of elements in each subarray. Then, the AND of all these sums is nonzero, where AND denotes the bitwise AND operation. Determine if it's possible. If it's possibl...
t = int(input()) while t > 0: n = int(input()) ar = [int(i) for i in input().split(" ")] ind = [1] i = 0 while i < 30 and len(ind) < 2: ind.clear() x = 1 << i for j in range(n): if ar[j] & x > 0: ind.append(j) i += 1 length = len(ind) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF B...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
import sys input = lambda: sys.stdin.readline().rstrip() for _ in range(int(input())): n, k = map(int, input().split()) a = [(ord(i) - 97) for i in input()] d = [([0] * 26) for i in range((k + 1) // 2)] ans = 0 for i in range(len(a)): d[min(i % k, k - i % k - 1)][a[i]] += 1 for i in d: ...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR 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 BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR V...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
t = int(input()) def most_f(List): return max(set(List), key=List.count) for test in range(t): n, k = [int(x) for x in input().split()] arr = list(input()) allsame = True count = 0 end = k ev = 0 if n % 2 == 0: ev = 1 for i in range(0, k // 2 + ev): valk = [] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR 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 FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
def max_counter(a): d = {} for i in a: d[i] = d.get(i, 0) + 1 return max(d.values()) for _ in range(int(input())): n, k = map(int, input().split()) s = list(input()) ans = 0 for i in range(k): ans += ( len(s[i::k]) + len(s[n - i - 1 :: -k]) ...
FUNC_DEF ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER RETURN FUNC_CALL VAR FUNC_CALL VAR 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 FOR VAR FUNC_CALL VAR VAR VAR ...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
for xyz in range(0, int(input())): n, k = map(int, input().split()) s = input() c = 0 for i in range(0, k): ac = [0] * 26 r = i while r < n: ac[ord(s[r]) - 97] += 1 r += k r = k - i - 1 while r < n: ac[ord(s[r]) - 97] += 1 ...
FOR VAR FUNC_CALL VAR NUMBER 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 FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER VAR VAR ASSIGN VA...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
printn = lambda x: print(x, end="") inn = lambda: int(input()) inl = lambda: list(map(int, input().split())) inm = lambda: map(int, input().split()) ins = lambda: input().strip() DBG = True BIG = 10**18 R = 10**9 + 7 def ddprint(x): if DBG: print(x) def foo(s, n, k): ccnt = [([0] * 26) for i in rang...
ASSIGN VAR FUNC_CALL VAR VAR STRING 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 FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER N...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
for _ in range(int(input())): a, b = map(int, input().split(" ")) c = input() rat = a // b cost = 0 for i in range(b): f = [] g = [] for j in range(rat): f.append(c[i + j * b]) f.append(c[a - 1 - i - j * b]) h = set(f) for k in h: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR VAR EXPR...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
for _ in range(int(input())): n, k = map(int, input().split()) s = input() ans = [] if k % 2 == 1: ran = k // 2 + 1 else: ran = k // 2 for i in range(ran): temp = [] start = i end = k - i - 1 for j in range(n // k): if i != k // 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 IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR BIN_...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
I = lambda: list(map(int, input().split())) for _ in range(int(input())): n, k = I() s = input() x = 0 for i in range(k // 2): al = [0] * 26 for j in range(i, n, k): al[ord(s[j]) - 97] += 1 al[ord(s[(j // k + 1) * k - j % k - 1]) - 97] += 1 x += sum(al) - ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR BIN_OP FUNC_CALL...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
T = int(input()) while T > 0: T -= 1 n, k = map(int, input().split()) s = input() length = n / k ans = 0 halfk = k // 2 if k % 2 == 0 else k // 2 + 1 for i in range(halfk): d = {} for ch in s[i::k]: ch = ord(ch) if ch in d: d[ch] += 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
import sys t = int(sys.stdin.readline()) for _ in range(t): n, k = map(int, sys.stdin.readline().split()) s = sys.stdin.readline()[:-1] x = n // k ans = 0 left, right = 0, k - 1 while left < right: arr = [0] * 26 for j in range(x): arr[ord(s[left + k * j]) - 97] += 1...
IMPORT 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 NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VA...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
import sys input = sys.stdin.readline def main(): testNum = int(input()) for testcase in range(testNum): n, k = map(int, input().split()) s = list(input())[:n] res = 0 used = [True] * n empty = [True] * k for i in range(n): if used[i]: ...
IMPORT ASSIGN VAR VAR FUNC_DEF 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 VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR A...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
t = int(input()) cases = [] for _ in range(t): a = [int(i) for i in input().split()] n = a[0] k = a[1] string = input() cases.append((k, string)) for k, string in cases: l = len(string) n = l // k ans = 0 for i in range(k // 2): d = {} for j in range(i, l, k): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMB...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
T = int(input()) for _ in range(T): n, k = map(int, input().split()) s = input() i = 0 tc = 0 k1 = k while i < k: A = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
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 NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER N...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
def Bfs(id, n, k, visited: list): queue1, queue2 = [], [] visited[id] = True queue1.append(id) while queue1: i = queue1.pop() queue2.append(i) if i + k < n and not visited[i + k]: visited[i + k] = True queue1.append(i + k) if i - k >= 0 and not vis...
FUNC_DEF VAR ASSIGN VAR VAR LIST LIST ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR N...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
from sys import stderr def count_min_to_equalize(cs): c_counts = [(0) for _ in range(ord("z") - ord("a") + 1)] for c in cs: c_counts[ord(c) - ord("a")] += 1 return len(cs) - max(c_counts) for _ in range(int(input())): n, k = map(int, input().split(" ")) s = input() n_min = 0 s_ne...
FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL ...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) s = input() c = 0 for i in range(0, k // 2): d = {} g = 0 for j in range(i, n, k): g += 1 if s[j] not in d: d[s[j]] = 0 d[s[j]] += 1 for j in range(k -...
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 FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
t = int(input()) res = [] for i in range(t): summ_all = 0 n, k = map(int, input().split()) s = input() ans = [([0] * 26) for j in range((k + 1) // 2)] for j in range(n): ans[min(j % k, k - j % k - 1)][ord(s[j]) - 97] += 1 for j in ans: summ = 0 maximum = 0 for k i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP V...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
def main(): n, k = map(int, input().split()) s = input() dct = dict() b = 0 if k % 2 == 1: b = 1 for i in range(k // 2 + b): dct[i] = dict() for i in range(0, k // 2 + b): for r in range(0, n // k): if not s[k * r + i] in dct[i]: dct[i][s[k...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR FO...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
t = int(input()) for _ in range(t): n, k = [int(x) for x in input().split()] s = input() l = [] for i in range(k): l.append([]) for i in range(n): l[i % k].append(s[i]) ans = 0 for i in range(k // 2): x = l[i] + l[k - 1 - i] dict = {} for j in range(le...
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 LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
for t in range(int(input())): n, k = map(int, input().split()) s = input() div = n // k ans = 0 if k % 2 == 0: a = k // 2 else: a = k // 2 + 1 for i in range(a): arr = [0] * 26 for j in range(div): if i != k - 1 - i: arr[ord(s[j * k...
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 VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP ...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
from sys import stdin input = stdin.readline def A(): t = int(input()) for _ in range(t): a, b, c, d = map(int, input().split()) x, y, x1, y1, x2, y2 = map(int, input().split()) netr = b - a netu = d - c if x1 == x2 and (a > 0 or b > 0): print("No") ...
ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER EXPR FUN...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
t = int(input()) while t: n, k = [int(i) for i in input().split()] s = input() ans = 0 reps = n // k for i in range((k - 1) // 2 + 1): mem = {} for j in range(i, n, k): if s[j] in mem: mem[s[j]] += 1 else: mem[s[j]] = 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR VAR VAR ...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
def solve(n, k, s): i = 0 j = k - 1 ans = 0 while i <= j: fre = [(0) for i in range(0, 26)] for ind in range(i, len(s), k): fre[ord(s[ind]) - 97] += 1 if i != j: for ind in range(j, len(s), k): fre[ord(s[ind]) - 97] += 1 ans += sum(...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
t = int(input()) for _ in range(t): n, k = list(map(int, input().split())) s = str(input()) lis = [([0] * 26) for i in range((k + 1) // 2)] for i in range(n): lis[min(i % k, k - i % k - 1)][ord(s[i]) - 97] += 1 ans = 0 for i in range(k // 2): a = max(lis[i]) b = sum(lis[i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
from sys import stdin t = int(stdin.readline()) for _ in range(t): n, k = map(int, stdin.readline().split()) s = stdin.readline() su = 0 for x in range(k // 2): d = {} for i in range(n // k): if s[x + k * i] in d: d[s[x + k * i]] += 1 else: ...
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 FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR BIN_OP VAR VAR IF VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR BIN_OP...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
for _ in range(int(input())): n, k = tuple(map(int, input().split())) s = input() dicts = [{} for i in range((k - 1) // 2 + 1)] for num, mydict in enumerate(dicts): for i in range(num, len(s), k): if s[i] not in mydict: mydict[s[i]] = 0 mydict[s[i]] += 1 ...
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 VAR ASSIGN VAR DICT VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR A...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
for krya in range(int(input())): n, k = map(int, input().split()) st = input() ans = 0 stn = [] for i in range(k): stn.append(st[i::k]) newlst = [] for i in range(k // 2): newlst.append(stn[i] + stn[-1 - i]) if k % 2 == 1: newlst.append(stn[k // 2]) for i in n...
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 FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
tt = int(input()) while tt != 0: n, k = map(int, input().split()) s = list(input()) ans = 0 p = n // k t = -1 if k % 2 == 0: t = k // 2 else: t = k // 2 + 1 for i in range(t): temp = [0] * 26 for j in range(n // k): if s[j * k + i] == s[j * k +...
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 FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER FOR VA...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
for _ in range(int(input())): n, k = map(int, input().split()) s = input() a = 0 for i in range(0, k): b = [0] * 26 for j in range(i, n, k): b[ord(s[j]) - 97] += 1 b[ord(s[k - 1 - j]) - 97] += 1 a += sum(b) - max(b) print(a // 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 FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER VAR BIN_OP FUNC_CAL...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
from itertools import groupby for _ in range(int(input())): n, k = map(int, input().split()) s = input() x = n // k c = 0 if k % 2 != 0: k2 = k // 2 + 1 else: k2 = k // 2 for i in range(k2): l = [] l1 = [] for j in range(0, x): if i != k /...
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 VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST AS...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
import sys def answer(n, k, s): odd = False if k % 2 == 1: l = k // 2 + 1 odd = True else: l = k // 2 base = ord("a") cnt = [[(0) for j in range(26)] for i in range(l)] for i in range(n): c_num = i % k if c_num >= l: c_num = k - (c_num + 1) ...
IMPORT FUNC_DEF ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN V...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
a = int(input()) for _ in range(a): b, c = map(int, input().split()) d = input() ans = 0 for i in range(c // 2): now = i data = {} while now < b: if d[now] not in data: data[d[now]] = 0 data[d[now]] += 1 now += c now = c...
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 FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR DICT WHILE VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR NUMBER VAR VAR VAR NUMBER VAR VAR AS...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
import sys ne = [[]] word = [] def dfs(v, fd): dic = [0] * 26 st = [v] fd[v] = 1 dic[word[v]] = 1 while st: h = st.pop() for nei in ne[h]: if not fd[nei]: fd[nei] = 1 dic[word[nei]] += 1 st.append(nei) return sum(dic)...
IMPORT ASSIGN VAR LIST LIST ASSIGN VAR LIST FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR LIST VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER WHILE VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR FUNC...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
import sys input = lambda: sys.stdin.readline().rstrip() def calc(n, k, A): X = [([0] * 26) for _ in range((k + 1) // 2)] for i, a in enumerate(A): j = i % k j = min(j, k - 1 - j) X[j][a] += 1 return sum([(sum(x) - max(x)) for x in X]) T = int(input()) for _ in range(T): N, ...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR VAR VAR NUMBER RETURN FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUN...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
for test in range(int(input())): n, k = list(map(int, input().split())) s = input() ans = 0 for i in range(k // 2): cnt = 0 d = dict() maxn = 0 for j in range(i, n, k): cnt += 2 if s[j] not in d: d[s[j]] = 1 else: ...
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 VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF VAR VAR...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
t = int(input()) while t > 0: n, k = map(int, input().split()) s = input() count = 0 no = n // k for i in range(0, k // 2): l = [] for x in range(26): l.append(0) for j in range(no): l[ord(s[j * k + i]) - 97] += 1 l[ord(s[k * (j + 1) - 1 - ...
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 NUMBER ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VA...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
for i in range(int(input())): n, k = map(int, input().split()) t = input() ans = 0 for i in range(k // 2): b = {} h = i while h < n: if t[h] not in b: b[t[h]] = 1 else: b[t[h]] += 1 if t[k - h - 1] not in b: ...
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 FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR DICT ASSIGN VAR VAR WHILE VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR NUMBER VAR VAR VAR NUMBER IF VAR BIN_OP BIN_OP VAR ...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
import sys input = sys.stdin.readline t = int(input()) for _ in range(t): n, k = map(int, input().split()) s = input().rstrip() ans = 0 for i in range(k // 2): alph = [0] * 26 for j in range(n // k): alph[ord(s[j * k + i]) - ord("a")] += 1 alph[ord(s[j * k + k - ...
IMPORT ASSIGN VAR VAR 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 FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_O...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
from sys import stdin t = int(stdin.readline()) output = [] for tc in range(t): n, k = map(int, stdin.readline().split()) w = stdin.readline() e = [[] for i in range(n)] for i in range(n // 2): e[i].append(n - i - 1) e[n - i - 1].append(i) for i in range(n - k): e[i].append(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST 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 VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP B...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
testcases = int(input()) for testcase in range(testcases): temp = input() temp = temp.split() n = int(temp[0]) nlen = int(temp[1]) x = input() group = [] chunks, chunk_size = n, nlen group = [x[i : i + chunk_size] for i in range(0, chunks, chunk_size)] dicts = {} for i in group: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR NUMBER VAR VAR AS...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
for t in range(int(input())): n, k = [int(i) for i in input().split()] p = n // k s = input() a = [([0] * 26) for i in range(k)] for i in range(n): a[i % k][ord(s[i]) - ord("a")] += 1 a[i % k][ord(s[n - 1 - i]) - ord("a")] += 1 total = 0 for i in a: total += 2 * p - m...
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 BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING NUMB...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
from sys import stdin, stdout T = int(stdin.readline()) def func(s, k, i): a = [0] * 29 n = len(s) for u in i: j = u while j < n: a[ord(s[j]) - ord("a")] += 1 j = j + k sm = 0 mx = -1 for j in a: if j > mx: mx = j sm += j ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR VAR WHILE VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR ...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
import sys LI = lambda: list(map(int, sys.stdin.readline().strip("\n").split())) MI = lambda: map(int, sys.stdin.readline().strip("\n").split()) SI = lambda: sys.stdin.readline().strip("\n") II = lambda: int(sys.stdin.readline().strip("\n")) for _ in range(II()): n, k = MI() s = SI() ans = 0 for i in r...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL ...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
t = int(input()) run = 0 while run < t: n, k = map(int, input().split()) s = input() rep = int(n / k) units = [s[j * k : (j + 1) * k] for j in range(rep)] changes = 0 if k % 2 == 0: for i in range(k // 2): arr1 = [units[j][i] for j in range(rep)] arr2 = [units[j][...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
import sys input = sys.stdin.readline t = int(input()) for _ in range(t): n, k = map(int, input().split()) s = str(input()) c = [([0] * 26) for _ in range((k + 1) // 2)] for i in range(n): c[min(i % k, k - i % k - 1)][ord(s[i]) - ord("a")] += 1 ans = 0 if k % 2 == 0: for i in ra...
IMPORT ASSIGN VAR VAR 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 BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
import sys def f(l): d = {} for i in l: if i in d: d[i] += 1 else: d[i] = 1 return len(l) - max(d.values()) for i in range(int(sys.stdin.readline())): n, k = map(int, sys.stdin.readline().split()) s = input() print( sum(f(s[j::k] + s[k - 1 - j ...
IMPORT FUNC_DEF ASSIGN VAR DICT FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR 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 EXPR FUNC_CALL VAR BIN_OP FUNC_CALL ...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
from sys import stdin t = int(stdin.readline()) for _ in range(t): n, k = map(int, stdin.readline().split()) s = stdin.readline() cnt = [[(0) for i in range(26)] for j in range((k + 1) // 2)] for i in range(n): cnt[min(i % k, k - i % k - 1)][ord(s[i]) - ord("a")] += 1 ans = 0 for i in r...
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 VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR BIN...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
def count(s): a = [0] * 26 for x in s: a[ord(x) - 97] += 1 return len(s) - max(a) for _ in range(int(input())): n, k = map(int, input().split()) s = input() i = 0 p = [] for _ in range((k + 1) // 2): p.append([]) while i <= n - k: for j in range(0, (k + 1) /...
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR 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...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
def hamming_dist(a, b): n = len(a) d = [(1 if a[i] != b[i] else 0) for i in range(n)] return sum(d) def letter_frequencies(word, k): dict_list = [] for i in range(k // 2): sub_wrd1 = word[i::k] sub_wrd2 = word[k - i - 1 :: k] sub_wrd = sub_wrd1 + sub_wrd2 my_dict = ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR DICT FOR VAR VAR IF V...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) l = list(input()) ls = [] for i in range(26): ls.append(0) count = 0 if k % 2 == 1: i = k // 2 while i < n: ls[ord(l[i]) - 97] += 1 i += k maximum = max(ls) count ...
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 FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
for _ in range(int(input())): n, k = map(int, input().split()) s = [i for i in input()] mas = [s[i * k : i * k + k] for i in range(n // k)] num = [0] * 27 ans = 0 for i in range(k): for j in range(n // k): num[ord(mas[j][i]) - 97] += 1 num[ord(mas[j][k - 1 - i]) -...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FU...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
for h in range(int(input())): n, k = map(int, input().split()) s = input() matrix = [s[i : i + k] for i in range(0, n, k)] ans = 0 if k % 2 == 1: cnt = [0] * 26 for i in range(n // k): cnt[ord(matrix[i][k // 2]) - 97] += 1 ans += n // k - max(cnt) else: ...
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 VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR NUMBER VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR V...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
t = int(input()) for i in range(t): n, k = map(int, input().split()) s = input() d = {} i = 0 while i < n: q = s[i : i + k] for j in range(k // 2): if j not in d: d[j] = {} if q[j] not in d[j]: d[j][q[j]] = 0 if q[-j...
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 DICT ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR DICT IF VAR VAR VAR VAR A...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
q = int(input()) alph = "abcdefghijklmnopqrstuvwxyz" def to_arr(s): a = [0] * len(s) for i in range(len(s)): a[i] = alph.index(s[i]) return a for _ in range(q): n, k = map(int, input().split()) s = to_arr(input()) ans = 0 for i in range(k // 2): r = [0] * 26 ml = ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR RETURN 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 ...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
testcases = int(input()) for j in range(testcases): values = list(map(int, input().split())) n = values[0] k = values[1] words = [(ord(k) - 96) for k in input()] moves = 0 if k % 2 == 0: for s in range(k // 2): store1 = [(0) for i in range(26)] start = s ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMB...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
t = int(input()) for _ in range(t): count = 0 n, k = map(int, input().split()) l = input() s = list(l) for i in range(k): d = {} j = 0 while i + j * k < n: if s[i + j * k] in d: d[s[i + j * k]] += 1 else: d[s[i + j * k]]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR NUMBER WHILE BIN_OP VAR BIN_OP VAR VAR VAR IF VAR BIN_OP VAR BIN_OP VAR V...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
for t in range(int(input())): n, k = [int(i) for i in input().split()] s = input() ss = 0 mm = [] for i in range(0, k): kk = [0] * 26 for j in range(i, n, k): kk[ord(s[j]) - ord("a")] += 1 mm.append(kk) cc = [] for i in range(0, k // 2): tt = [(mm[...
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 ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
t = int(input()) for z in range(0, t): n, k = map(int, input().split()) word = [] ip = list(input()) temp = [] num = int(n / k) count = 0 for i in range(0, n): temp.append(ip[i]) count = count + 1 if count % k == 0: word.append(temp) temp = [] ...
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 LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR AS...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
t = int(input()) for i in range(t): inp1 = list(map(int, input().split())) n = inp1[0] k = inp1[1] s = input() anss = 0 for p in range(int(k / 2)): aplha = "" for j in range(int(n / k)): aplha = aplha + s[j * k + p] + s[(j + 1) * k - 1 - p] dicti = [0] * 28 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CA...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
for _ in range(int(input())): n, k = map(int, input().split()) p = n // k s = "0" + input() count = 0 for i in range(1, k // 2 + 1): dict = {} maxx = 0 for j in range(p): if s[j * k + i] in dict: dict[s[j * k + i]] += 1 else: ...
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 BIN_OP VAR VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BI...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) a = input() c = 0 for i in range(k // 2): d = dict() for j in range(i, n, k): if a[j] in d: d[a[j]] += 1 else: d[a[j]] = 1 for j in range(k - i - 1, n, k):...
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 FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUM...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
t = int(input()) for i in range(t): n, k = map(int, input().split()) s = list(input()) ans = 0 for i in range(k // 2): cnt = [(0) for i in range(26)] st = 0 while st + k - 1 < n: i1 = st + i i2 = st + (k - 1 - i) cnt[ord(s[i1]) - ord("a")] += 1...
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 NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP VAR VAR NUMBER VAR A...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
DEBUG = 0 def least_cost(alpha_cnt, k_clusters, i, mid): for k_wrd in k_clusters: ind_s = ord(k_wrd[i]) - 97 alpha_cnt[ind_s] += 1 if DEBUG: print(k_wrd, k_wrd[i], k_wrd[-i - 1]) print(ind_s) if not mid: ind_e = ord(k_wrd[-i - 1]) - 97 ...
ASSIGN VAR NUMBER FUNC_DEF FOR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR IF VAR EXPR FUNC_CALL V...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
for _ in range(int(input())): n, k = map(int, input().split()) s = input() ans = 0 for i in range(k // 2): l = [0] * 26 c = 0 for j in range(i, n, k): c += 1 val = ord(s[j]) - ord("a") l[val] += 1 for j in range(k - i - 1, n, k): ...
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 FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VA...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
from sys import stdin t = int(input()) for _ in range(t): n, k = map(int, stdin.readline().split()) s = stdin.readline().strip() ans = 0 vis = [(False) for i in range(n)] for i in range(n): if vis[i]: continue check = set() for j in range(i, n, k): ch...
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 FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
import sys input = sys.stdin.readline Q = int(input()) Query = [] for _ in range(Q): N, K = map(int, input().split()) S = list(input().rstrip()) Query.append((N, K, S)) for N, K, S in Query: ans = 0 L = N // K for r in range(K): if K % 2 == 0 and r >= K // 2: break i...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST 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 FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR FOR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CAL...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
import sys input = lambda: sys.stdin.readline().strip() ipnut = input for i in range(int(input())): n, k = map(int, ipnut().split()) s = list(ipnut()) l = n // k lol = [[] for _ in range(k)] lo = [[] for _ in range((k + 1) // 2)] for i in range(n): lol[i % k].append(s[i]) for i in r...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR 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 BIN_OP VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP BIN_OP VAR N...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
import sys def solve(): split = str.split t = int(sys.stdin.readline()) while t > 0: n, k = map(int, split(sys.stdin.readline())) s = sys.stdin.readline() ans = 0 index = 0 max_chars = [] mappend = max_chars.append while index <= (k - 1) // 2: ...
IMPORT FUNC_DEF ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR WHILE VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING AS...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
for t in range(int(input())): n, l = map(int, input().split()) s = input() d = n // l ans = 0 for k in range(0, l // 2): a = [(0) for o in range(26)] b = [(0) for o in range(26)] for p in range(k, n, l): a[ord(s[p]) - 97] += 1 b[ord(s[l - p - 1]) - 97]...
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 VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUN...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
t = int(input()) for i in range(t): n, k = map(int, input().split()) s = input() answer = 0 for j in range((k + 1) // 2): d = dict() o = j d[s[o]] = 1 o += k - 1 - j * 2 count = 1 if k == j * 2 + 1: if k == 1: o += 1 ...
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 FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER BIN_OP...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
def solve(ans): n, k = [int(x) for x in input().split()] s = input() occur = [([0] * 26) for i in range((k + 1) // 2)] for i in range(0, n, k): for j in range((k + 1) // 2): occur[j][ord(s[i + j]) - ord("a")] += 1 for j in range(k // 2): occur[j][ord(s[i + k - j -...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR VAR...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
t = int(input()) for _ in range(t): n, k = map(int, input().split()) s = list(input()) data = [] for j in range(k): temp = [] for l in range(n // k): temp.append(s[l * k + j]) data.append(temp) ans = 0 for i in range(k // 2): l1 = data[i] l1.ex...
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 FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL ...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
import sys def input(): return sys.stdin.readline().strip() def iinput(): return int(input()) def rinput(): return map(int, input().split()) def rlinput(): return list(map(int, input().split())) def main(): def pro(a, b, x, x1, x2): if (a == -2 * b or x != x1 or x != x2 or b == 0)...
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR 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 VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FUNC_DEF IF VAR BIN_OP NUMBER VAR VAR VAR VAR VAR VAR NUMBER VAR BIN_OP BIN_OP VAR VAR VAR...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
import sys input = sys.stdin.readline t = int(input()) for _ in range(t): N, K = map(int, input().split()) S = list(input())[:-1] table = [([0] * 26) for _ in range(K)] a = ord("a") for i in range(N): table[i % K][ord(S[i]) - a] += 1 smtable = [0] * K for k in range(26): for...
IMPORT ASSIGN VAR VAR 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 NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VA...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
T = int(input()) for test in range(T): N, K = list(map(int, input().split())) word = input() if K == 1: bins = [(0) for i in range(128)] for c in word: bins[ord(c)] += 1 print(N - max(bins[97:])) continue MDcount = N // K changes = 0 for pos in range(K...
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 IF VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR NUMBER ASSIGN...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
import sys reader = (s.rstrip() for s in sys.stdin) input = reader.__next__ def gift(): for _ in range(t): n, k = list(map(int, input().split())) string = input() res = [] for i in range(k // 2 + k % 2): res.append({}) for i in range(n // k): for j ...
IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_DEF 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 LIST FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR DICT FOR VAR FUNC_CALL VAR BIN_OP ...
Word $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \le i \le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \le i \le n-k$. For example, "abaaba" is a $3$-complete word, while "abccba" is not. Bob is given a word $s$ of length $n$ consisting of only l...
t = int(input()) for _ in range(t): n, k = [int(p) for p in input().split()] s = input() subStr = [] for i in range(0, n, k): subStr.append(s[i : i + k]) cnt = 0 p = k if k % 2 != 0: p += 1 for i in range(p // 2): letters = [0] * 26 for sub in subStr: ...
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 LIST FOR VAR FUNC_CALL VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER FO...