description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order. By solvin...
n, k, M = map(int, input().split()) t = sorted(map(int, input().split())) def calc(x): tot = x * sum(t) if tot > M: return 0 tans = x * (k + 1) for i in range(k - 1): if t[i] * (n - x) + tot <= M: tot += t[i] * (n - x) tans += n - x else: tan...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR IF VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR BIN_OP VAR VA...
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order. By solvin...
n, k, m = map(int, input().split()) l = list(map(int, input().split())) l.sort() sm = sum(l) ans = 0 for i in range(n + 1): if sm * i > m: break m1 = m - sm * i cnt = [n - i] * k cur = 0 res = (k + 1) * i while m1 > 0: if cur >= k or l[cur] > m1: break x = min...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP LIST BIN_...
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him t_{j} minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order. By solvin...
n, k, m = map(int, input().split()) nums = list(map(int, input().split())) result = -1 alltime = sum(nums) for made in range(n + 1): if alltime * made > m: break currentres = (k + 1) * made currenttime = m - made * alltime available = [] for item in nums: available.extend([item] * (n...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) s = input() cr = [] if n % 2 == 0: if p > n // 2: p = n - p + 1 else: p = p elif p > n // 2 + 1: p = n - p + 1 else: p = p for i in range(n // 2): if s[i] != s[n - 1 - i]: cr.append(i) count = 0 if len(cr) == 0: pass elif p - 1 > cr[-1]: ...
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 IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR IF VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VA...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) p -= 1 string_orig = input() if p >= (n + 1) // 2: string_orig = string_orig[::-1] p = n - p - 1 steps_rl = 0 string = list(string_orig) pos = p for i in range(p, (n + 1) // 2): c1, c2 = string[i], string[n - i - 1] if c1 != c2: diff = abs(ord(c1) - ord(c2)) ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR IF VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, x = map(int, input().split()) s = input() a = [0] * (n // 2) if n % 2 == 0: s1 = s[: n // 2] s2 = s[n // 2 :] else: s1 = s[: n // 2] s2 = s[n // 2 + 1 :] s2 = s2[::-1] if s1 == s2: print(0) exit() for i in range(n // 2): c = abs(ord(s1[i]) - ord(s2[i])) a[i] = min(26 - c, c) ans = sum...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR N...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) ans = [0] * n if p > (n + 1) // 2: p = ~(p - 1) % n + 1 s = input() for i in range(n // 2): ans[i] = min((ord(s[i]) - ord(s[~i])) % 26, (ord(s[~i]) - ord(s[i])) % 26) fz = 0 while fz < n and ans[fz] == 0: fz += 1 lz = n // 2 - 1 while lz >= 0 and ans[lz] == 0: lz -= 1 lz...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR IF VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_C...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, k = map(int, input().split(" ")) s = input() cnt = 0 hs = [0] * n for i in range(n // 2): if s[i] != s[n - i - 1]: hs[i] = min( abs(ord(s[i]) - ord(s[n - i - 1])), 26 - abs(ord(s[i]) - ord(s[n - i - 1])) ) hs[n - i - 1] = hs[i] cnt = 0 mind = -1 mxind = -1 if k <= n // 2: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_O...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = [int(x) for x in input().split()] p -= 1 atz = "qwertyuiopasdfghjklzxcvbnm" if len(atz) != 26: print("gone wrong") d = {} for i in atz: for j in atz: x = abs(ord(i) - ord(j)) x = min(x, 26 - x) d[i, j] = x s = input() i = 0 j = len(s) - 1 m = (n + 1) // 2 if p >= m: p = n - 1 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR DICT FOR VAR VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP NUMBER VAR ASSIGN VAR VAR VAR VA...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
from sys import stdin, stdout nmbr = lambda: int(stdin.readline()) lst = lambda: list(map(int, input().split())) def fn(ch1, ch2): m1 = (ord(ch1) - ord(ch2) + 26) % 26 m2 = (ord(ch2) - ord(ch1) + 26) % 26 return min(m1, m2, 26 - m1, 26 - m2) for _ in range(1): n, p = lst() s = input() hf = ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER NUMBER RETURN FUNC_CALL VAR VAR VAR BIN_OP NUMBE...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, c = map(int, input().split()) s = input() ans = 0 first = n - 1 last = 0 for i in range(n // 2): if s[i] != s[n - i - 1]: first = min(first, i) last = max(last, i) a = ord(s[i]) - 97 b = ord(s[n - i - 1]) - 97 change = min(a, b) + 26 - max(a, b) ans += min(abs(b - ...
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 NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP FUNC_...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
def main(): def parser(): while 1: data = list(input().split(" ")) for number in data: if len(number) > 0: yield number input_parser = parser() gets = lambda: next(input_parser) def getNum(): data = gets() try: ...
FUNC_DEF FUNC_DEF WHILE NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split(" ")) s = list(input()) change = 0 leftchange = set() rightchange = set() p -= 1 for x in range(n // 2): if s[x] != s[n - x - 1]: leftchange.add(x) rightchange.add(n - x - 1) change += min( abs(ord(s[x]) - ord(s[n - x - 1])), ord(s[x]) + ord("z") - o...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_O...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) temp = list(input()) check = [] if p > n // 2: p = n + 1 - p cnt = 0 for i in range(n // 2): if temp[i] != temp[n - 1 - i]: check += [i + 1] a = min( abs(ord(temp[i]) - ord(temp[n - 1 - i])), 26 - abs(ord(temp[i]) - ord(temp[n - 1 - i])), ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR LIST BIN_OP VAR NUMBER ASSIGN VAR FUN...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, pos = map(int, input().split()) s = input() c = 0 indxi = [] indxj = [] if n > 1: i = 0 j = n - 1 while i < n // 2 and j >= n // 2: if s[i] != s[j]: indxi.append(i) indxj.append(j) c += min(abs(ord(s[i]) - ord(s[j])), abs(abs(ord(s[i]) - ord(s[j])) - 26)) ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR FUNC_CAL...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) text = input() p -= 1 if p >= len(text) // 2: text = text[-1::-1] p = len(text) - p - 1 maxr = p minl = p for i in range(p, len(text) // 2): if text[i] != text[-i - 1]: maxr = i flag = 0 for i in range(p, -1, -1): if text[i] != text[-i - 1]: minl = i ans ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BI...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) s = input() l = 0 r = n - 1 ans = 0 a = "abcdefghijklmnopqrstuvwxyz" dic = {} for i in range(26): dic[a[i]] = i + 1 dis = [] left = {} right = {} while l < r: if s[l] != s[r]: ans += min(abs(dic[s[l]] - dic[s[r]]), 26 - abs(dic[s[l]] - dic[s[r]])) left[l] = 1 ...
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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR DICT ASSIGN VAR DICT WHILE VAR VAR IF VAR VAR ...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, pos = (int(x) for x in input("").split()) s = input("") def dis(a, b): a = ord(a) b = ord(b) return min(abs(a - b), abs(a + 26 - b), abs(b + 26 - a)) d = [dis(s[i], s[len(s) - i - 1]) for i in range((len(s) + 1) // 2)] pos -= 1 if pos >= (len(s) + 1) // 2: pos = len(s) - pos - 1 for rightmost, v ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_C...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
import sys def dbg(*args): print("D:", *args, file=sys.stderr) n, p = map(int, input().split()) s = input() if s == s[::-1]: print("0") else: sz = len(s) if p > sz // 2: p = sz - p else: p -= 1 l, r = 0, sz // 2 - 1 while s[l] == s[-l - 1]: l += 1 while s[r] =...
IMPORT FUNC_DEF EXPR FUNC_CALL VAR STRING VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) p -= 1 s = input() arr = [ (lambda x, y: min(abs(x - y), 26 - abs(y - x)))(ord(s[i]), ord(s[n - i - 1])) for i in range(n // 2) ] p = min(p, n - p - 1) f, l = 0, len(arr) - 1 for a in arr: if a != 0: break else: f += 1 for a in reversed(arr): if a != ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
def palindrome_transformation(n, p, nams): current = p - 1 half = n // 2 if current >= half: current = n - current - 1 weight = [0] * half for i in range(half): diff = abs(ord(nams[i]) - ord(nams[n - i - 1])) if diff > 13: diff = 26 - diff weight[i] = diff...
FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP NUMBER VA...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
def piche_se(n, p, s): s = [i for i in s] sol = 0 if 1 == 1: if n % 2 == 0: if p < n // 2: tota = n // 2 last = -1 else: tota = n last = n // 2 - 1 elif p <= n // 2: tota = n // 2 + 1 ...
FUNC_DEF ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER IF NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VA...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = list(map(int, input().split())) a = input() if p > n // 2: a = a[::-1] p = n - p else: p = p - 1 ans = 0 lo = hi = p i = p while i >= 0: if a[i] != a[n - i - 1]: lo = i mx = max(ord(a[i]) - ord("a") + 1, ord(a[n - i - 1]) - ord("a") + 1) mi = min(ord(a[i]) - ord("a") + 1, ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR WHILE VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VA...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
from sys import stdin n, p = map(int, input().split()) s = stdin.readline().rstrip("\n") l = [0] * n for i in range(n // 2): if s[i] != s[n - 1 - i]: a = abs(ord(s[i]) - ord(s[n - 1 - i])) b = ord(s[i]) - 97 + 1 + 122 - ord(s[n - 1 - i]) c = ord(s[n - 1 - i]) - 97 + 1 + 122 - ord(s[i]) ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER VAR AS...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
MOD = 10**9 + 7 I = lambda: list(map(int, input().split())) n, p = I() s = input() a = [0] * n p -= 1 if p >= n // 2: p = n - p - 1 for i in range(n // 2): a[i] = abs(ord(s[i]) - ord(s[n - i - 1])) a[i] = a[n - i - 1] = min(a[i], 26 - a[i]) ind = 0 s = sum(a) s = s // 2 if s == 0: print(0) else: l =...
ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASS...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
def finddistance(a, b): k1 = abs(122 - ord(b) + ord(a) - 96) k2 = abs(ord(b) - ord(a)) k3 = abs(122 - ord(a) + ord(b) - 96) k4 = abs(ord(a) - ord(b)) return min([k1, k2, k3, k4]) n, p = map(int, input().split()) s = list(input()) a = [] c = 0 d = 0 count = 0 for i in range(n // 2): if i == n -...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR F...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) string = input() def palindrome_transformer(string, n, p): if n % 2 == 0: s_1 = string[0 : int(n / 2)] s_2 = string[int(n / 2) : len(string)] s_1_reversed = "" for numbers in range(int(len(string) / 2) - 1, -1, -1): s_1_reversed += s_1[n...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP FUNC_CALL VAR ...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
ALPHA = ord("z") - ord("a") + 1 def is_problem(s): return [int(s[i] != s[-i - 1]) for i in range(len(s))] def count_problems(s): return sum(is_problem(s)) def change(a, b): return min(abs(a - b), ALPHA - abs(a - b)) def solve(p, s): if p >= len(s) // 2: s = list(reversed(s)) p = ...
ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR FUN...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
def findMirror(counter, n): return n - counter - 1 def checkForward(counter, n, st): total = 0 done = [0] * (n + 1) mid = int(n / 2) high = 0 if counter <= mid: high = mid else: high = n - 1 i = 0 steps = 0 while counter <= high: i = i + 1 if don...
FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VA...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = list(map(int, input().split())) l = input() i = 0 j = n - 1 pos = [] ans = 0 while i <= j: if l[i] != l[j]: if abs(p - i) < abs(p - j): pos.append(i + 1) else: pos.append(j + 1) x = max(ord(l[i]), ord(l[j])) y = min(ord(l[i]), ord(l[j])) ans = a...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CA...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) w = list(input()) d = [] done = [] for i in range(n // 2): if w[i] != w[-i - 1]: temp = int(abs(ord(w[i]) - ord(w[-i - 1]))) d.append(min(temp, 26 - temp)) done.append(i) if p <= n // 2: p -= 1 else: p = n - p if len(done) == 0: print(0) else: ...
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 LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL ...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) s = input() ans = 0 if p > n // 2: s = s[::-1] p = n - p + 1 l = [] last = p temp = p l.extend(s) while temp > 0: yo = min( abs(ord(s[temp - 1]) - ord(s[n - temp])), 26 - abs(ord(s[temp - 1]) - ord(s[n - temp])), ) ans += yo l[temp - 1] = l[n - te...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP F...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
I = lambda: list(map(int, input().split())) def ge(x): return ord(x) - 97 n, k = I() s = input() x = 0 ind = [] k -= 1 for i in range(n // 2): p = min((ge(s[i]) - ge(s[n - i - 1])) % 26, (ge(s[n - i - 1]) - ge(s[i])) % 26) if p != 0: ind.append(i if k < n // 2 else n - i - 1) x += p if ind !...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
def cost(a, b): return min(abs(ord(b) - ord(a)), 26 - abs(ord(b) - ord(a))) def pal(x, n): return n - x - 1 n, pt = map(int, input().split()) pt -= 1 s = input() if pt >= n // 2: s = s[::-1] pt = pal(pt, n) cos = [cost(s[i], s[pal(i, n)]) for i in range(n)] start = -1 end = -1 for i in range(n): ...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP NUMBER FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, s = [int(i) for i in input().split()] st = input() mid = n // 2 if s > mid: s = n - s else: s -= 1 diff = 0 lis = [] for i in range(mid): if st[i] != st[n - 1 - i]: t1 = ord(st[i]) - 97 t2 = ord(st[n - 1 - i]) - 97 test1 = t2 - t1 if test1 < 0: test1 += 26 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
s = input() p = int(s.split()[1]) s = input() n = int(len(s)) a = [] if p > n // 2: p = n - p + 1 sum = 0 if n == 1: print("0") quit() for i in range(n // 2): j = int(n - i - 1) q = abs(ord(s[j]) - ord(s[i])) a.append(min(q, 26 - q)) sum += a[i] i = 0 while (a[i] == 0) & (i < p - 1): i +...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR B...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
import sys def find_cost(a, b): ch = "abcdefghijklmnopqrstuvwxyz" min_cost = sys.maxsize a, b = min(a, b), max(a, b) c = ch.index(b) - ch.index(a) d = 25 - ch.index(b) + (ch.index(a) - 0) + 1 return int(min(c, d)) n, k = map(int, input().split()) st = input() mid = (n + 1) // 2 s, e = int(),...
IMPORT FUNC_DEF ASSIGN VAR STRING ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) s = input() main, m = "abcdefghijklmnopqrstuvwxyz", dict() for i in range(26): m[main[i]] = i p = min(p - 1, n - p) b, a, ans, f, ff = -1, -1, 0, True, True for i in range(n // 2): if s[i] != s[n - 1 - i]: ans += min(abs(m[s[i]] - m[s[n - i - 1]]), 26 - abs(m[s[i]] - m[s...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR STRING FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN VAR VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP V...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) s = input() res = 0 left = 10**9 right = 0 for i in range(n // 2): if s[i] != s[n - i - 1]: if p < n // 2: if i < p: left = min(left, i) else: right = max(right, i) elif i < n - p + 1: left = min(lef...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_C...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = [int(x) for x in input().split()] Estrin = input() steps = 0 pwasmid = False parin = 0 if len(Estrin) > 1: if len(Estrin) % 2 == 0: par = True else: par = False parin = 1 if par and p > n // 2: p = n - p + 1 if par == False and p > n // 2 + 1: p = n - p + 1...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VA...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) p = min(p, n + 1 - p) p -= 1 s = input() ans = 0 t = [] for i in range(n // 2): if s[i] != s[-i - 1]: ans += min( abs(ord(s[i]) - ord(s[-i - 1])), 26 - abs(ord(s[i]) - ord(s[-i - 1])) ) t.append(i) if not t: ans = 0 elif t[0] >= p: ans += ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR F...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
from sys import stdin def solve(tc): n, p = map(int, stdin.readline().split()) n -= 1 p -= 1 s = stdin.readline() half = n // 2 lo = 0 hi = n if p <= half: hi = half - 1 if n % 2 == 0 else half else: lo = half + 1 while lo < hi and s[lo] == s[n - lo]: lo...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR NU...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) t = input() k = n // 2 d = [0] * (k + 1) for i in range(k): d[i] = abs(ord(t[i]) - ord(t[n - i - 1])) if 2 * d[i] > 26: d[i] = 26 - d[i] p = n - p if p > k else p - 1 if d.count(0) == k + 1: print(0) else: i, j = 0, k while d[i] == 0: i += 1 while...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP NUMBER VAR VAR NUMBE...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, k = map(int, input().split()) s = input() k -= 1 k = min(k, n - k - 1) a = -1 b = 0 ans = 0 l = 0 for i in range(n // 2): j = abs(ord(s[i]) - ord(s[n - 1 - i])) j = min(j, 26 - j) if j > 0 and a == -1: a = i if j > 0: b = i l += j a = min(a, n - a - 1) b = min(b, n - b - 1) if l =...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUN...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().strip().split()) p = p - 1 A = input().strip() s1 = 0 p1 = 0 p2 = float("Inf") for i in range(int(len(A) // 2)): if A[i] != A[-1 * i - 1]: if i > p1: p1 = i if i < p2: p2 = i a = ord(A[i]) - ord(A[-1 * i - 1]) s1 += min([a % 26, -1 * a ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) s = input() ans = [] for i in range(len(s)): ans.append(s[i]) sm1 = 0 la1 = 0 flag = 0 for i in range(len(ans) // 2): if ans[i] != ans[-1 * (i + 1)] and flag == 0: sm1 = i + 1 flag = 1 if ans[i] != ans[-1 * (i + 1)]: la1 = i + 1 if sm1 == 0: print...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER ...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) p -= 1 if p >= n // 2: p = n - 1 - p chars = input() tmp = [abs(ord(chars[i]) - ord(chars[n - 1 - i])) for i in range(n // 2)] tmp = [min(x, 26 - x) for x in tmp] val1, val2 = -1, -1 for i in range(len(tmp)): if tmp[i] > 0: if val1 == -1: val1 = i val...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
def solve(n, p, s): if p >= n // 2: p = n + 1 - p to_be_changed = [i for i in range(n // 2) if s[i] != s[n - i - 1]] if not to_be_changed: return 0 tmp = [ min((ord(s[i]) - ord(s[n - i - 1])) % 26, -(ord(s[i]) - ord(s[n - i - 1])) % 26) for i in to_be_changed ] up...
FUNC_DEF IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER BIN_OP BIN_OP FUNC...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = list(map(int, input().split())) string = input() def calc_delta(s): def get_min_shift(i): ord_diff = abs(ord(s[i]) - ord(s[n - i - 1])) return min(ord_diff, 26 - ord_diff) return {i: get_min_shift(i) for i in range((n + 1) // 2)} def palindrome(s): deltas = calc_delta(s) off...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN FUNC_CALL VAR VAR BIN_OP NUMBER VAR RETURN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP V...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = [int(x) for x in input().split()] l = list(input()) flag = 0 if p > n // 2: flag = 1 ans = 0 p -= 1 ff = p ffm = p for i in range(n): if i > n - i - 1: break x = ord(l[i]) - 97 y = ord(l[n - i - 1]) - 97 if x != y: ans += min(abs(x - y), 26 - max(x, y) + min(x, y)) if ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VA...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) p -= 1 s = input() ans = 0 idx = 0 pos = [] while idx < n // 2: if s[idx] != s[n - 1 - idx]: diff = abs(ord(s[idx]) - ord(s[n - 1 - idx])) ans += min(diff, 26 - diff) if p >= n // 2: pos.append(n - 1 - idx) else: pos.append(idx...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VA...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
f = lambda c: ord(c) - ord("a") dalp = lambda x, y: min(abs(x - y), abs(x + 26 - y), abs(y + 26 - x)) dist = lambda i, j: min(abs(i - j), abs(i + n - j), abs(j + n - i)) read = lambda: list(map(int, input().split())) n, p = read() a = [f(i) for i in input()] pr, sf = [], [] cnt = 0 for i in range(n // 2): if a[i] !...
ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP V...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) s = input() mid = n // 2 - 1 p -= 1 if p >= mid: s = s[::-1] p = n - p - 1 l = -1 r = -1 i = p res = 0 while i >= 0: if s[i] != s[n - i - 1]: l = i diff = min( abs(ord(s[i]) - ord(s[n - i - 1])), 26 - abs(ord(s[i]) - ord(s[n - i - 1])) ) ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR VAR BIN_OP BIN...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) p -= 1 s = input() if p >= n // 2: p = n - 1 - p l = 0 r = n // 2 - 1 while l < n // 2 and s[l] == s[n - 1 - l]: l += 1 while r >= 0 and s[r] == s[n - 1 - r]: r -= 1 ans, ch = 0, 0 for i in range(l, r + 1): temp = abs(ord(s[i]) - ord(s[n - 1 - i])) ch += min(temp, 26...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER WHILE VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER WHILE VAR NUMBER VAR ...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = [int(i) for i in input().split()] p -= 1 p = min(p, n - p - 1) s = input() ans = 0 m1 = None m2 = 0 for i in range(n): if n - i - 1 < i: break if s[i] != s[-i - 1]: if m1 is None: m1 = i m2 = max(m2, i) ans += min(abs(ord(s[i]) - ord(s[-i - 1])), 26 - abs(ord(s[i])...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NONE ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER IF VAR NONE ASSIGN...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) p -= 1 st = input().strip() l = 0 h = n // 2 - 1 if p > h: p = n - 1 - p inside = False ans = 0 i = 0 H = -1 while i <= h: if st[i] != st[n - 1 - i]: if not inside: l = i inside = True H = i ans += min( abs(ord(st[i]) - ord(st[...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR BIN_...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) ans = 0 s = input() for i in range(n // 2): a = [] a.append(s[i]) a.append(s[n - 1 - i]) a.sort() ans += min(ord(a[1]) - ord(a[0]), ord("z") - ord(a[1]) + 1 + ord(a[0]) - ord("a")) p -= 1 n -= 1 mid = n // 2 if p > mid: p = n - p st = 0 e = mid while s[st] == s[n...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VA...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
def main(): s = "abcdefghijklmnopqrstuvwxyz" d = { (a, b): min((ord(a) - ord(b)) % 26, (ord(b) - ord(a)) % 26) for a in s for b in s } n, m = map(int, input().split()) s, res, n, m = input(), 0, n - 1, min(m - 1, n - m) idx = [i for i, a in zip(range((n + 1) // 2), s) if ...
FUNC_DEF ASSIGN VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL V...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
input_ = list(map(int, input().split())) n, p = input_[0], input_[1] pal_ = list(input()) pal_ = [(ord(letter) - 96) for letter in pal_] diff_ = 0 dist_ = 0 p_down = p - 1 <= int(n / 2) - 1 if n % 2 == 0: bad_ = list() for i in range(int(n / 2)): if pal_[int(n / 2) - 1 - i] != pal_[int(n / 2) + i]: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR N...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) s = input() mid = int(n / 2) alphabets = "".join([chr(i) for i in range(97, 123)]) * 2 def min_diff(alp1, alp2, alphabets=alphabets): alp1, alp2 = min(alp1, alp2), max(alp1, alp2) return min( abs(alphabets.find(alp1) - alphabets.find(alp2)), abs(alphabets.find(...
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 NUMBER ASSIGN VAR BIN_OP FUNC_CALL STRING FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER FUNC_DEF VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VAR FUNC_CALL ...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) s = list(map(ord, input())) if p > n // 2: p = n - p else: p -= 1 l = n // 2 r = -1 ans = 0 for i in range(n // 2): d = abs(s[i] - s[n - i - 1]) d = min(d, 26 - d) if d: l = min(l, i) r = max(r, i) ans += d print(ans + r - l + min(abs(r - p), ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) s = input() ans = 0 p -= 1 if n % 2 == 1 and p == n // 2 and n != 1: p -= 1 ans += 1 cnt = 0 for i in range(n): if n - 1 - i <= i: break if s[i] != s[n - 1 - i]: cnt += 1 if p >= n // 2 and n != 1: h = "" for i in range(n - 1, -1, -1): h +...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR NUMBER VAR VAR IF VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VA...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) s = input().rstrip() p = min(p, n - p + 1) Count = 0 M = l = r = X = p for i in range(0, n // 2): C = min( abs(ord(s[i]) - ord(s[-i - 1])), abs( ord("z") - max(ord(s[i]), ord(s[-i - 1])) + min(ord(s[i]), ord(s[-i - 1])) ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL ...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = [int(i) for i in input().split()] str = input() p -= 1 if p != n / 2 and p == n // 2: press = 0 for i in range(p + 1, n): press += 1 if str[i] != str[n - i - 1]: s = min(ord(str[i]), ord(str[n - i - 1])) g = max(ord(str[i]), ord(str[n - i - 1])) press +...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VA...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
def dosomething(a, b): m1 = min(a, b) m2 = max(a, b) m1 = ord(m1) - 97 m2 = 122 - ord(m2) return min(abs(ord(a) - ord(b)), m1 + m2 + 1) arr = [int(x) for x in input().split()] n, k = arr[0], arr[1] s = input() mid = n // 2 if n == 1: print(0) else: if n & 1 == 1: if k == mid: ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR VAR RETURN FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) s = [ord(c) for c in input()] ans = 0 left = right = -1 for i in range(n // 2): diff = abs(s[i] - s[n - i - 1]) ans += min(diff, 26 - diff) if s[i] != s[n - i - 1]: if left == -1: left = i right = i if left == -1: print(0) else: p -= 1 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP NUMBER VAR IF VAR VAR VAR BIN_OP B...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
ad = ord("z") - ord("a") + 1 def mc(a, b): pd = abs(ord(a) - ord(b)) return min(pd, ad - pd) def fd(v, r): for c in r: if not v[c]: return c def mp(s, n, p): cl = n // 2 v = [(s[c] == s[-(c + 1)]) for c in range(cl)] rv = range(cl) if p >= cl: p = n - p - 1 ...
ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_DEF FOR VAR VAR IF VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER VAR FUN...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) p = p - 1 a = input() fn = 0 ln = n // 2 sum_val = 0 allzero = True flag = True for i in range(n // 2): diff = abs(ord(a[i]) - ord(a[n - i - 1])) val = min(diff, 26 - diff) sum_val += val if val == 0 and flag: fn += 1 else: flag = False if val != ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR ...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
lis = "abcdefghijklmnopqrstuvwxyz" def dis(a, b): aa = lis.index(a) bb = lis.index(b) m = 27 m1 = 27 ans = 100 for i in range(26): if aa < i: m = min(i - aa, 26 - i + aa) else: m = min(aa - i, 26 - aa + i) if bb < i: m1 = min(i - bb, ...
ASSIGN VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP NUMBER VAR VAR IF ...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = input().split() n = int(n) p = int(p) s = input() p -= 1 c = 0 p = min(p, n - 1 - p) l = p r = p for i in range(p - 1, -1, -1): if s[i] != s[n - i - 1]: l = i c += min( abs(ord(s[i]) - ord(s[n - i - 1])), abs(26 - abs(ord(s[i]) - ord(s[n - i - 1]))), ) for i in...
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR BIN_OP BIN_O...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) p -= 1 a = list(input()) if p >= n // 2: p = n - 1 - p leftSum = 0 mLeft = -1 rightSum = 0 mRight = p for i in range((n + 1) // 2): if a[i] != a[n - 1 - i]: temp = min( abs(ord(a[i]) - ord(a[n - 1 - i])), 1 + ord("z") - max...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR BIN_OP BIN...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, pos = map(int, input().split()) pos -= 1 s = input().rstrip() cost = [0] * n left, right = [], [] for i in range(n // 2): cost[i] = abs(ord(s[i]) - ord(s[n - i - 1])) cost[i] = min(cost[i], abs(26 - cost[i])) cost[n - i - 1] = cost[i] if cost[i]: left.append(i) right.append(n - i - 1)...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VA...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
import sys input = sys.stdin.readline n, p = map(int, input().split()) s = input().rstrip() if p >= n // 2: s = s[::-1] p = n + 1 - p p -= 1 ans1 = 0 ans2 = 0 l = 10**6 r = -1 for i in range(n // 2): if s[i] != s[n - 1 - i]: l = min(l, i) r = max(r, i) use = set() if l <= p <= r: if r !...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR ...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = list(map(int, input().split())) string = input() n, p = n - 1, p - 1 if p > n // 2: p = n - p ans = 0 left, right = -1, -1 for i in range(n // 2 + 1): ch, corresponding = string[i], string[n - i] if ch != corresponding: if left == -1: left = i else: right = i ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR VA...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
def change(a, b): a, b = ord(a) - 96, ord(b) - 96 a, b = max(a, b), min(a, b) return min(a - b, 26 + b - a) def mini(arr, p): if len(arr) == 0: return 0 if arr[-1] <= p: return p - arr[0] if arr[0] >= p: return arr[-1] - p return min(arr[-1] - p, p - arr[0]) + (arr[...
FUNC_DEF ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP NUMBER VAR VAR FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR RETURN BIN_OP VAR VAR NUMBER IF VAR NUM...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
def getUnpaired(s): unpaired = set() for i in range(0, n // 2): if s[i] != s[n - i - 1]: unpaired.add(i) return unpaired def getDist(c1, c2): dist1 = abs(ord(c1) - ord(c2)) dist2 = abs(ord(c1) + 26 - ord(c2)) dist3 = abs(ord(c2) + 26 - ord(c1)) return min(dist1, dist2, ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR AS...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) l = list(input()) flag = 0 min1 = max1 = -1 sum = 0 for i in range(n // 2): if l[i] != l[n - 1 - i]: if flag == 0: min1 = i + 1 flag = 1 max1 = i + 1 s1 = abs(ord(l[i]) - ord(l[n - 1 - i])) s2 = 26 - s1 sum += min(s1, s...
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 VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
for _ in range(1): n, p = [int(i) for i in input().split()] if n - p < p - 1: p = 1 + n - p p -= 1 s = input() to_go = int(n / 2) - 1 i = 0 j = n - 1 l = [] while i <= to_go: if s[i] != s[j]: l.append(i) i += 1 j -= 1 if len(l) == 0: ...
FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIS...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
def dc(c, d): x, y = ord(c) - ord("a"), ord(d) - ord("a") return min(abs(x - y), 26 - max(x, y) + min(x, y)) def ds(s1, s2): r = 0 a, b = 10**5, -1 for i in range(len(s1)): c, d = s1[i], s2[i] r += dc(c, d) if c != d: a = min(a, i) b = max(b, i) ...
FUNC_DEF ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING RETURN FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL V...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) s = list(input()) p -= 1 d = [0] * (n // 2 + 1) for i in range(n // 2): x = ord(s[i]) - ord(s[n - i - 1]) d[i] = min(abs(x), 26 - abs(x)) if p >= n // 2: p = n - 1 - p if sum(d) == 0: print(0) exit() i, j = 0, n // 2 while d[i] == 0: i += 1 while d[j] == 0: j...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
def calc(c1, c2): x = abs(ord(c1) - ord(c2)) return min(x, 26 - x) a, b = map(int, input().split(" ")) strx = input() if a % 2 == 0: if b > a // 2: b = a + 1 - b left = strx[: a // 2] right = strx[a // 2 :] right = right[::-1] dist = [calc(left[i], right[i]) for i in range(a // 2)]...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR BIN_OP NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR VAR BIN...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
def distchar(a, b): a = ord(a) - ord("a") b = ord(b) - ord("a") if a > b: a, b = b, a return min(b - a, a + 26 - b) def dist(i, p, n): if p >= i: sign = 1 else: sign = -1 return sign * min(abs(p - i), abs(n - 1 - i - p)) [n, p] = [int(s) for s in input().split()] ...
FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING IF VAR VAR ASSIGN VAR VAR VAR VAR RETURN FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR FUNC_DEF IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER RETURN BIN_OP VAR FUNC_CALL VAR FUNC_CALL ...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
from sys import stdin, stdout def main(): from sys import stdin, stdout n, o = list(map(int, stdin.readline().split())) string = stdin.readline().strip() if n & 1: s1 = string[: n // 2] s2 = string[n // 2 + 1 :] rev = s2[::-1] minim = 0 indexlist = [] f...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN V...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().strip().split()) arr = input() lis = [] flag = 0 mins = -1 maxs = -1 f = 0 sums = 0 for x in range(n // 2): if arr[x] != arr[-(x + 1)]: if f == 0: mins = x f = 1 if maxs < x: maxs = x if abs(ord(arr[x]) - ord(arr[-(x + 1)])) <= 13: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, p = map(int, input().split()) s = input() p = n - p if p > n // 2 else p - 1 left, right, steps = n // 2, -1, 0 for i in range(n // 2): x = abs(ord(s[i]) - ord(s[-i - 1])) steps += min(x, 26 - x) if x != 0: left = min(left, i) right = max(right, i) if steps: print(steps + right - left...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VA...
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. There is a cursor pointing at some symbol of the string. Suppose that c...
n, m = input().split(" ") n = int(n) m = int(m) s = input() a = n // 2 ans = [] for i in range(0, a): ans.append( min(abs(ord(s[i]) - ord(s[n - i - 1])), 26 - abs(ord(s[i]) - ord(s[n - i - 1]))) ) x = sum(ans) if m > a: m = n + 1 - m g1 = 0 g2 = a - 1 d = 0 for i in range(0, a): if ans[i] != 0: ...
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR V...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
def solve(): s = input() if "aa" in s or "bb" in s or "cc" in s: print(-1) return syms = s + "@" ans = ["@"] for i, sym in enumerate(s): if sym != "?": ans.append(sym) continue for x in "abc": if x != ans[-1] and x != syms[i + 1]: ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR IF STRING VAR STRING VAR STRING VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR LIST STRING FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR FOR VAR STRING IF VAR VAR NUMBER VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL V...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a = list(map(int, input().split())) ref = [0, 1, 2, 3] x = sum(a) for i in range(4): b = a[:] res = [] for j in range(x): b[i] -= 1 res.append(ref[i]) if i == 0: i = 1 elif i == 3: i = 2 elif i == 1: if b[0] > 0: i =...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
from sys import stdin, stdout read = lambda: map(int, stdin.readline().split()) I = lambda: stdin.readline() a, b, c, d = read() ind = 0 if a + c < b + d else 1 res = [(0) for i in range(a)] + [(2) for i in range(c)] for i in range(b): res.insert(ind, 1) ind += 2 for j in range(d): res.insert(ind, 3) i...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER FOR VAR...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a, b, c, d = map(int, input().split()) seq = [] nums = [a, b, c, d] def solve(a, b, c, d, second): for i in range(3): while nums[i] != 0 and nums[i + 1] != 0: if len(seq) == 0: if second: seq.append(i + 1) nums[i + 1] -= 1 ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST VAR VAR VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER WHILE VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER IF FUNC_CALL VAR VAR NUMBER IF VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a, b, c, d = map(int, input().split()) p = 0 e = [] if a > b: if c == 0 and d == 0 and a == b + 1: for j in range(a + b): if j % 2 == 0: e.append(0) else: e.append(1) else: p = 1 elif d > c: if a == 0 and b == 0 and d == c + 1: ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST IF VAR VAR IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR IF VAR NUMBER VAR...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
numbers = list(map(int, input().split(" "))) def solve(numbers, x): n = sum(numbers) a = [None for i in range(n)] for i in range(n): if not numbers[x]: return a[i] = x numbers[x] -= 1 if not sum(numbers): break if x and numbers[x - 1]: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NONE VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR RETURN ASSIGN VAR VAR VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NU...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
T = 1 MAX = 3 * 10**5 + 10 for t in range(1, T + 1): a, b, c, d = map(int, input().split()) a_, b_, c_, d_ = a, b, c, d if a == 0 and b == 0: if abs(c - d) > 1: print("NO") continue if c > d: print("YES") ans = "2 " * (c - d > 0) + "3 2 " * d ...
ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR IF VAR NUMBER VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING I...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a = list(map(int, input().split(" "))) for i in range(4): res = [] b = [] if a[i] != 0: for j in range(4): b.append(a[j]) j = i b[j] -= 1 res.append(j) while 1: chk = 1 if j == 0: if b[j + 1] > 0: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR WHILE NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR BIN_OP...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
import sys input = sys.stdin.readline a, b, c, d = map(int, input().split()) n = a + b + c + d res = [-1] * n if a + c + 1 == b + d: for i in range(0, 2 * b - 1, 2): res[i] = 1 for i in range(2 * b, n, 2): res[i] = 3 for i in range(1, n, 2): if (res[i - 1], res[i + 1]) == (1, 1): ...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR IF BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_C...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
import sys a, b, c, d = map(int, input().split()) a0, b0, c0, d0 = a, b, c, d ab, bc, cd = [], [], [] while a and b: a -= 1 b -= 1 ab.extend([0, 1]) if a: if not c0 and not d0 and a == 1: ab.append(0) print("YES") print(*ab) else: print("NO") sys.exit() while c a...
IMPORT ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR LIST LIST LIST WHILE VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR LIST NUMBER NUMBER IF VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR V...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
import sys from itertools import combinations input = sys.stdin.readline INF = 10**9 a, b, c, d = [int(item) for item in input().split()] n = a + b + c + d if n == 1 and a == 1: print("YES") print(0) exit() elif n == 1 and d == 1: print("YES") print(3) exit() diff = a + c - (b + d) if abs(diff)...
IMPORT ASSIGN VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EX...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
a, b, c, d = map(int, input().split()) zeros, ones, twos, threes = a, b, c, d s = a + b + c + d r = [-1] * s for i in range(0, s, 2): if a > 0: r[i] = 0 a -= 1 elif c > 0: r[i] = 2 c -= 1 else: break for i in range(s - 1 - s % 2, -1, -2): if d > 0: r[i] = ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER ...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
def solve1(arr, start): wynik = [] id = start while True: if arr[id] == 0: if sum(arr) == 0: break return "NO\n" arr[id] -= 1 wynik.append(str(id)) if id == 0: id = 1 elif id == 1: id = 0 if arr[0] > 0 el...
FUNC_DEF ASSIGN VAR LIST ASSIGN VAR VAR WHILE NUMBER IF VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN STRING VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER NUMBER NUMBER IF VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER NUMBER NUMBER IF VAR NU...
An integer sequence is called beautiful if the difference between any two consecutive numbers is equal to $1$. More formally, a sequence $s_1, s_2, \ldots, s_{n}$ is beautiful if $|s_i - s_{i+1}| = 1$ for all $1 \leq i \leq n - 1$. Trans has $a$ numbers $0$, $b$ numbers $1$, $c$ numbers $2$ and $d$ numbers $3$. He wan...
from sys import stdin def iinput(): return int(stdin.readline()) def sinput(): return input() def minput(): return map(int, stdin.readline().split()) def linput(): return list(map(int, stdin.readline().split())) a = linput() ref = [0, 1, 2, 3] x = sum(a) for i in range(4): b = a[:] seq...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN 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 ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL ...