description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for q in range(int(input())): line = list(map(int, input())) cou = [0] * 10 for i in line: cou[i] += 1 ans = len(line) - 2 for i in range(10): ans = min(ans, len(line) - cou[i]) for a in range(10): for b in range(10): fl = False i = 0 a...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR VAR FOR VAR FUNC_CA...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for _ in range(int(input())): s = input() n = len(s) ans = 0 for i in range(10): for j in range(10): f = True c = 0 for k in range(n): if f and int(s[k]) == i: c += 1 f = False elif not f ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR FUNC_CALL...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for g in range(int(input())): s = input() slov = [0] * 10 data = [0] * 10 for i in range(len(s)): data[int(s[i])] += 1 ans = max(data) for i in range(10): slov[i] = 1 for i in range(len(s)): if slov[int(s[i])] == 1: slov[int(s[i])] = 0 data = [...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL ...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for _ in range(int(input())): s = input() n = len(s) ans = len(s) - 1 for i in range(0, 10): cnt = 0 for j in s: if j != str(i): cnt += 1 ans = min(ans, cnt) for i in range(0, 10): for j in range(0, 10): if i == j: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER FO...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
n = int(input()) for i in range(n): s = input() l = len(s) d = dict() for i in "0123456789": d[i] = 0 for i in s: d[i] = d[i] + 1 d = sorted(d.items(), key=lambda x: x[1], reverse=True) maxi = d[0][1] arr = d for i in range(len(arr)): for j in range(len(arr)):...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR STRING ASSIGN VAR VAR NUMBER FOR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSI...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for m in [*open(0)][1:]: kj = [0] * 100 for i in map(int, m[:-1]): for j in range(10): kj[10 * i + j] = kj[10 * j + i] + 1 print(len(m) - 1 - max(max(kj) & ~1, *kj[::11]))
FOR VAR LIST FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR BIN_OP VAR BIN_OP BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR BIN_OP FUNC_CALL ...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
def mergeSort(L, R, a): i = j = k = 0 while i < len(L) and j < len(R): if L[i] < R[j]: a[k] = 0 i += 1 else: a[k] = 1 j += 1 k += 1 while i < len(L): a[k] = 0 i += 1 k += 1 while j < len(R): a[k] = 1 ...
FUNC_DEF ASSIGN VAR VAR VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR NUMBER VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR NUMBER VAR NU...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
import sys input = sys.stdin.readline t = int(input()) for r in range(t): s = input().strip("\n") n = len(s) d = {} for i in s: try: d[i] += 1 except: d[i] = 1 if len(d) == n: print(n - 2) elif len(d) == 1: print(0) else: mini ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FU...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for i in range(int(input())): a = list(map(int, input())) z = len(a) + 1 a1 = [0] * 10 a2 = [z] * 10 a3 = list(range(10)) for j, x in enumerate(a): a1[x] += 1 if a2[x] == z: a2[x] = j a4 = [x[0] for x in sorted(zip(a3, a2), key=lambda q: q[1])] b = [[(0) for y...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR V...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
t = int(input()) for i in range(t): a = input() b = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] k = 0 for j in range(10): for l in range(10): q = str(b[j]) w = str(b[l]) e = 0 r = 0 d = 0 for f in a: d += 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR AS...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
t = int(input()) for i in range(t): lin = input() a = {"0": 0, "1": 0, "2": 0, "3": 0, "4": 0, "5": 0, "6": 0, "7": 0, "8": 0, "9": 0} b = { "0": -1, "1": -1, "2": -1, "3": -1, "4": -1, "5": -1, "6": -1, "7": -1, "8": -1, "9": -...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING STRING STRING ST...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
from itertools import product T = int(input()) for _ in range(T): s = input() mn, n = len(s), len(s) for a, b in product(list("0123456789"), list("0123456789")): cc = 0 for ch in s: if cc % 2 == 0: if ch == a: cc += 1 elif ch == b:...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER IF VAR VA...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for _ in range(int(input())): s = input() ans = 0 for d1 in "1234567890": for d2 in "1234567890": d11 = d1 d21 = d2 cur_ans = 0 for c in s: if c == d11: cur_ans += 1 d11, d21 = d21, d11 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR STRING FOR VAR STRING ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR ...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
t = int(input()) def max_len(two, num): two = str(two) if len(two) == 1: two = "0" + two lenth = 0 to_check = 0 for i in num: if i == two[to_check]: to_check = (to_check + 1) % 2 lenth += 1 if lenth % 2 == 0: return lenth return lenth - 1 d...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN VAR RETURN BIN_OP VAR NUMBER FUNC_...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for _ in range(int(input())): s = input() dp = [[(0) for i in range(10)] for j in range(10)] mx = 0 for i in range(10): sl = str(i) for j in range(10): nl = str(j) fi, ei = -1, -1 used = 0 for k in range(len(s)): if i == j a...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUM...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
t = int(input()) def swap(p): b = p[0] p[0] = p[1] p[1] = b return p def calculate_delets(s, pat): or_pat = pat.copy() res = 0 for el in s: if el == pat[0]: pat = swap(pat) else: res += 1 if pat != or_pat: res += 1 return res for ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR VAR ASSIGN ...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
def giveCost(x, y, s): cost = 0 lookFor = x l = 0 for i in s: if i != lookFor: cost += 1 else: lookFor = y if lookFor == x else x l += 1 return cost if l % 2 == 0 or x == y else cost + 1 for _ in range(int(input())): s = list(map(int, list(in...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR NUMBER RETURN BIN_OP VAR NUMBER NUMBER VAR VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIG...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for _ in range(int(input())): n = input() cnt = 2 f = [(0) for i in range(10)] for i in range(10): for c in n: if c == str(i): f[i] += 1 for j in range(i + 1, 10): ind1, ind2 = True, True cnt1, cnt2 = 0, 0 for c in n: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR VAR IF VAR FUNC_CALL VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBE...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
import sys input = sys.stdin.readline def name(arr): patterns = {} highest = 0 count = 0 for i in range(10): for j in range(10): first = 0 found = False for char in arr[:-1]: if i == j: if char == str(i): ...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR NUMBER IF VAR VAR IF VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER IF VAR...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
def test(s, c): matrix = [ [ [-1, 0], [-1, 0], [-1, 0], [-1, 0], [-1, 0], [-1, 0], [-1, 0], [-1, 0], [-1, 0], [-1, 0], ], [ [-1, 0], [-1, 0], ...
FUNC_DEF ASSIGN VAR LIST LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER ...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
t = int(input()) for _ in range(t): s = input() data = [] req = [] for _ in range(10): temp = [] temp1 = [] for _ in range(10): temp.append(0) temp1.append(-1) data.append(temp) req.append(temp1) for i in s: i = int(i) f...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VA...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
n = int(input()) for i in range(n): m = 0 arr1 = str(input()) for j in range(0, 10): for k in range(0, 10): if j < k: coun = 0 y = 0 for t in range(len(arr1)): if coun == 0 and arr1[t] == str(j): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR FUNC_CALL VAR VAR...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for _ in range(int(input())): n = input() ans = 2 * int(100000.0) for pair in range(100): i = 0 s = str(pair) if len(s) == 1: s = "0" + s d = 0 for j in n: if j != s[i]: d += 1 else: i = 1 - i ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
from sys import stdin tt = int(stdin.readline()) nn = "0123456789" for loop in range(tt): s = stdin.readline() s = s[:-1] ans = len(s) for fi in nn: for sc in nn: state = 0 now = 0 for i in s: if i == fi and state == 0: now...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER ASSIG...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
t = int(input()) for tc in range(t): s = str(input()) freq = {} for i in range(10): freq[str(i)] = 0 for i in s: freq[i] += 1 res = len(s) - max(freq.values()) for i in range(10): for j in range(10): flag = 0 cnt = 0 for k in s: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CA...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
t = int(input()) def min_erase(c, s): erase = 0 t = 0 for d in s: if d == c[t]: t ^= 1 else: erase += 1 if c[0] != c[1] and t == 1: erase += 1 return erase for _ in range(t): s = input() ans = len(s) for x in range(10): for y in...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VA...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for _ in range(int(input())): s = input() a = [] for i in s: a.append(int(i)) b = [] n = len(s) for i in range(10): for j in range(10): check = False cnt = 0 st = 11 nd = 11 for k in a: if k == i or k == ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR V...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
import sys reader = (s.rstrip() for s in sys.stdin) input = reader.__next__ nn = "0123456789" def gift(): for _ in range(t): s = input() ans = len(s) for fi in nn: for sc in nn: state = 0 now = 0 for i in s: i...
IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR STRING FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER AS...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
T = int(input()) while T: s = input() D = {} for i in range(len(s)): if int(s[i]) in D: D[int(s[i])].append(i) else: D[int(s[i])] = [i] m = 0 for i in D: m = max(m, len(D[i])) for i in D: for j in D: if i != j: a...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR LIST VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR V...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
from itertools import product for _ in range(int(input())): s = input() res = min(2, len(s)) for c1, c2 in product("0123456789", repeat=2): cnt = 0 idx = 0 for c in s: if c == (c1 if idx == 0 else c2): cnt += 1 idx = 1 - idx res = ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR STRING NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR BIN_...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
import sys input = sys.stdin.readline t = int(input()) for _ in range(t): s = [int(ch) for ch in input().rstrip()] ans = 0 for d1 in range(0, 10): for d2 in range(0, 10): if d1 == d2: cnt = s.count(d1) ans = max(ans, cnt) continue ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NU...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
def func(a, x, y): res = 0 for c in a: if c == x: res += 1 temp = x x = y y = temp if x != y and res % 2 == 1: res -= 1 return res for _ in range(int(input())): a = [int(x) for x in input()] ans = 0 for x in range(10): ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
t = int(input()) def func(s, j, k): c = 0 if j == k: for b in s: if int(b) != j: c += 1 else: v = 0 for b in s: if v == 0: if int(b) != j: c += 1 else: v = (v + 1) % 2 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER IF VAR VAR FOR VAR VAR IF FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER ...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
T = int(input()) for _ in range(T): s = input() n = len(s) ans = n - 2 A = [(0) for i in range(10)] for i in range(10): for j in range(10): l = 0 st = 0 B = [str(i), str(j)] for val in s: if val == B[st]: l =...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FUNC_CALL VAR VAR F...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
import sys def count_alternation(s, a, b): n = len(s) for i in range(n): if s[i] == a: break if s[i] == b: a, b = b, a break i1 = 0 for i in range(n)[::-1]: if s[i] == b: i1 = i break flip = {a: b, b: a} which ...
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR DICT VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
t = int(input()) while t: t -= 1 s = input() if len(list(set(s))) == 1: print("0") else: x = [ "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRI...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for _ in range(int(input())): s = input() m = 0 for i in range(10): m = max(m, s.count(str(i))) ans1 = len(s) - m second = 0 for i in range(10): for j in range(i + 1, 10): last = "" c = 0 for k in s: if k == str(i) or k == str(j...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASS...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
import sys input = sys.stdin.readline inf = int(10000000000.0) t = int(input()) while t: t -= 1 s = input().strip() n = len(s) d = dict() for i in s: if i in d: d[i] += 1 else: d[i] = 1 m1 = max(d.values()) m2 = 0 for i in range(10): for j...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
t = int(input()) for _ in range(0, t): st = str(input()) if len(st) <= 2: print(0) continue ans = 2 for i in range(10): for j in range(10): temp = 0 for char in st: if temp & 1: if char == str(j): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER IF VAR FUNC_CALL VAR VAR VAR...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
t = int(input()) for _ in range(t): l = [int(i) for i in list(input())] ans = float("INF") for i in range(10): for j in range(10): count = 0 now = 1 for k in l: if now == 1: if k != i: count += 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER IF VAR VA...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
t = int(input()) for _ in range(t): s = input() counts = {} for i in s: if i in counts: counts[i] += 1 else: counts[i] = 1 longest = max(counts.values()) for a1 in "0123456789": for a2 in "0123456789": length = 0 found_a1 = Fals...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR STRING FOR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR IF VAR VAR VAR NUMBER ASSIGN V...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
import sys input = sys.stdin.readline aaaa = list() for kek in range(int(input())): s = input().split()[0] ans = 0 for i in range(10): for j in range(10): flg = True answer = 0 for x in s: if flg and int(x) == i: answer += 1 ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
def list_input(): return list(map(int, input().split())) def multiple_input(): return map(int, input().split()) def solve(a, b): res = 0 for it in s: if it == a: res += 1 a, b = b, a if res % 2 != 0 and a != b: res -= 1 return res for _ in range(int(...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VA...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
t = int(input()) for _ in range(t): s = list(str(input())) d = [0] * 10 for i in range(len(s)): d[int(s[i])] += 1 max_len = max(d) for a in range(0, 10): for b in range(0, 10): now_len = 0 p = a for i in range(len(s)): if int(s[i]) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBE...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
import sys input = sys.stdin.readline def solve(char): ind = 0 cnt = 0 for c in s: if c == char[ind]: cnt += 1 ind ^= 1 if char[0] != char[1]: cnt = cnt // 2 * 2 return len(s) - cnt t = int(input()) for _ in range(t): s = input()[:-1] ans = len(s)...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER RETURN BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASS...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
def check(a, b): ok = False cnt = 0 for i in range(len(u)): if ok and u[i] == a: cnt += 1 ok = False elif not ok and u[i] == b: cnt += 1 ok = True if a == b: return cnt return cnt - cnt % 2 ans = [] for stp in range(int(input(...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR RETURN VAR RETURN BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
def main(): t = int(input()) for i in range(t): s = input() answer = 10**9 for i in range(9): for j in range(i + 1, 10): a = str(i) b = str(j) last = "a" count = 0 for f in s: ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF VAR ...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
from sys import stdin, stdout q = int(input()) for i in range(q): s = input() sum1 = 0 flag = 0 for i in range(10): for j in range(10): maxi = 0 flag = 0 for k in s: if flag == 0: if int(k) == i: max...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
T = int(input()) for t in range(T): s = input() mx = 0 arr = [] for i in range(10): arr.append([]) cnt = 0 for k in s: arr[int(k)].append(cnt) cnt += 1 for i in range(9): for j in range(i + 1, 10): odd = 0 even = 0 m, n = 0,...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR LIST ASSIGN VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for _ in range(int(input())): s = input() n = len(s) pairs = [] for i in range(10): for j in range(10): pairs.append(str(i) + str(j)) maxx = 0 for i in pairs: c = 0 v = i[0] for j in range(n): if s[j] == v: c += 1 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FU...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
from sys import stdin for _ in range(int(stdin.readline())): t = stdin.readline().strip() ans = 0 for i in range(10): cand1 = str(i) for j in range(10): cand2 = str(j) pos = 0 flag = False for k in t: if k == cand1 and flag == ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VA...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
def everythingfine(s, n): for i in range(n): if s[i] != s[(i + 2) % n]: return False return True for _ in range(int(input())): s = input() n = len(s) maxi = 0 temp = list("0123456789") d = dict() for i in temp: d[i] = s.count(i) maxi = max(maxi, d[i]...
FUNC_DEF FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR RETURN NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR VAR FUNC_CA...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
def hhh(s, u, v): c = b = 0 for i in range(len(s)): if b == 0: if s[i] == u: x = u y = v b = 1 elif s[i] == v: x = v y = u b = 1 elif b == 1: if s[i] == y: ...
FUNC_DEF ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR ASSIGN VAR NUMBER RETURN VAR FOR VAR...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for _ in range(0, int(input())): l = list(input()) d = {} for i in range(0, len(l)): if int(l[i]) in d: d[int(l[i])].append(i) else: d.update({int(l[i]): [i]}) odd_res = 0 even_res = 999999999 for i in d: odd_res = max(len(d[i]), odd_res) odd_r...
FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR DICT FUNC_CALL VAR VAR VAR LIST VAR ASSIGN VAR NUMBER ASSIGN VAR NUM...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for _ in range(int(input())): s = input() n = len(s) cnt = [(0) for i in range(10)] for i in s: cnt[int(i)] += 1 arr = [] maxa = 0 for i in range(10): for j in range(10): tmp = 0 c = 0 p = 1 if i != j: for k in s...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSI...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
def f(s, n): if n % 2 != 0: return False else: p = s[0] q = s[1] for i in range(0, n, 2): if s[i] != p: return False for i in range(1, n, 2): if s[i] != q: return False return True def g(s, i, j): k = 0...
FUNC_DEF IF BIN_OP VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR VAR VAR RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for qwerty in range(int(input())): s = input() ans = 10**8 for i in range(10): t = 0 for j in s: if int(j) != i: t += 1 ans = min(ans, t) for a in range(10): for b in range(10): q = 0 t = 0 for j in s: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VA...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
t = int(input()) for i in range(t): s = input() pair = [] res = [] for i in range(10): for j in range(10): pair.append([i, j]) for i in range(100): turn = pair[i][0] c = 0 for j in range(len(s)): if int(s[j]) != turn: c += 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
t = int(input()) for _ in range(t): s = list(input()) res = len(s) - 2 for i in range(10): for j in range(10): cur, ci, cj = 0, 0, 0 ii, jj = str(i), str(j) for c in s: if ci == cj and c == ii: ci += 1 elif ci > ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR VAR V...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
import sys def make_pat(p): bit = 0 size = 0 for i in range(len(arr)): if bit == 0 and arr[i] == p[0]: bit = 1 size += 1 elif bit == 1 and arr[i] == p[1]: bit = 0 size += 1 if p[0] == p[1]: return size elif size % 2 == 0: ...
IMPORT FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER RETURN VAR IF BIN_OP VAR NUMBER NUMBER RETURN VAR RETURN NUMBER ASSIGN VAR FUNC...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
t = int(input()) for _ in range(t): s = input() n = len(s) ans = [0] * 10 for i in range(n): ans[ord(s[i]) - ord("0")] = ans[ord(s[i]) - ord("0")] + 1 ans.sort() mx = ans[9] for i in range(10): for j in range(10): c = 0 if j == i: conti...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING BIN_OP VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING NUMBER EXPR FUNC...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
from sys import stdin for _ in range(int(input())): a = stdin.readline().rstrip() d = {} le = len(a) for i in range(le): x = d.get(a[i], 0) if x: d[a[i]] += 1 else: d[a[i]] = 1 d = dict(sorted(d.items(), key=lambda x: x[1], reverse=True)) m = max(...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER A...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
def answer(A): d = {} for i in A: if i not in d: d[i] = 1 else: d[i] += 1 maxi = max(d.values()) for i in range(0, 10): for j in range(0, 10): if i != j: count = 0 search = str(i) for k in range(l...
FUNC_DEF ASSIGN VAR DICT FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR IF VAR FUNC...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
def main(): return "\n".join( map(str, (nCharactersToEraseFrom(input()) for _ in range(int(input())))) ) def nCharactersToEraseFrom(string): repetition = { "0": 0, "1": 0, "2": 0, "3": 0, "4": 0, "5": 0, "6": 0, "7": 0, "8": 0...
FUNC_DEF RETURN FUNC_CALL STRING FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASS...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
from sys import stdin, stdout k = "" def yark(a, i, j): z = 0 p = str(i) f = p for k in a: if k == f: z += 1 f = p if f != p else str(j) if i != j and z & 1: z -= 1 return z for t in range(int(stdin.readline())): a = stdin.readline() ans = 0 ...
ASSIGN VAR STRING FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
def solve(): s = input() n = len(s) dic = {} occ = {} for i in range(0, n): if s[i] not in dic: dic[s[i]] = [i] occ[s[i]] = 1 else: dic[s[i]].append(i) occ[s[i]] += 1 dic2 = {} maxx = 2 for d in dic: others = { ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR ASSIGN VAR VAR VAR LIST VAR ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR DICT STRING STRI...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for _ in range(int(input())): s = input() n = len(s) ans = n - 2 g = {i: [] for i in "0123456789"} for i in range(n): g[s[i]].append(i) for a in "0123456789": for b in "0123456789": cs = 0 i = j = 0 aa = g[a] bb = g[b] a...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR LIST VAR STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR FOR VAR STRING FOR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
import sys readline = sys.stdin.readline def solve(): S = readline().rstrip() N = len(S) odds = [S.count(str(i)) for i in range(10)] odds_max = max(odds) ans = N - max(odds) for i in range(10): if odds[i] * 2 <= odds_max: continue for j in range(i + 1, 10): ...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP V...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for s in [*open(0)][1:]: a = [0] * 10 b = [0] * 10 c = [0] * 100 i = 0 for x in map(int, s[:-1]): for j in range(10): c[10 * j + x] += (a[j] > a[x]) * 2 i += 1 a[x] = i b[x] += 1 print(i - max(b + c))
FOR VAR LIST FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR BIN_OP BIN_OP NUMBER VAR VAR BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
T = int(input()) l = [] for i in range(10): for j in range(i, 10): l.append([]) l[-1].append(str(i)) l[-1].append(str(j)) def solve(): if len(set(s)) == 1: return 0 val = 0 for i in range(55): l1 = [x for x in s if x in l[i]] if len(l1) == 0: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR LIST EXPR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FUNC_DEF IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER FOR VAR ...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
def solve(s, n): ans = n - 1 for a in range(10): for b in range(10): cnt1 = 0 cnt2 = 0 f = "fst" for i in range(n): if f == "fst": if s[i] == a: cnt1 += 1 f = "snd" ...
FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR IF VAR STRING IF VAR VAR VAR VAR NUMBER ASSIGN VAR STRING IF VAR VAR VAR VAR NUMBER ASSIGN VAR STRING IF VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for _ in range(int(input())): s = input() digits = "0123456789" total = len(s) for i in digits: for j in digits: if i != j: count = 0 order = 0 for d in s: if d == i and not order: count += 1 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR FOR VAR VAR IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VA...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
from sys import stdin input = stdin.readline def solve(a, b): a, b = str(a), str(b) curr = None first = None cnt = 0 for i in s: if not first: if a == i: first = a curr = b cnt += 1 elif b == i: first ...
ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NONE ASSIGN VAR NONE ASSIGN VAR NUMBER FOR VAR VAR IF VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER RETURN VAR VAR VAR BIN_...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
t = int(input()) for _ in range(t): s = input() n = len(s) maxx = 0 maxxs = 0 for i in range(0, 10): maxxs = max(maxxs, s.count(str(i))) for i in range(0, 100): cnt = 0 y = str(i) if len(y) == 1: y = "0" + y f = 0 for j in range(n): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUN...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
from sys import stdin def r(): return stdin.readline().strip() def r_t(tp): return map(tp, r().strip().split()) def r_a(tp): return list(r_t(tp)) def solve(t): occur = [(0) for _ in range(10)] for x in t: occur[int(x)] += 1 ans = float("inf") for x in occur: ans = min...
FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VA...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
pairs = tuple((i, j) for i in range(10) for j in range(10) if i != j) for _ in range(int(input())): s = tuple(int(i) for i in input()) ans = [] for digit in range(10): counter = s.count(digit) while ans and len(s) - counter < ans[-1]: ans.pop() ans.append(len(s) - counter...
ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR BIN_OP FUNC_CALL VAR VAR VAR VAR N...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for _ in range(int(input())): a = input() ans = 0 for i in range(10): for j in range(10): t = 0 for s in a: if t % 2: if int(s) == i: t += 1 elif int(s) == j: t += 1 if...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
t = int(input()) for t_ in range(t): s = input() best = 0 for a in range(10): for b in range(10): c = 0 state = 0 for n in range(len(s)): if s[n] == str(a) and state == 0: c += 1 state = 1 eli...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR VA...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
from sys import stdin input = stdin.readline def help(): stri = list(input().strip()) n = len(stri) if n <= 2: print(0) return seti = list(set(stri)) ans = 0 for i in range(10): ans = max(ans, max(stri.count(str(i)), ans)) for a in seti: for b in seti: ...
ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FO...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
t = int(input()) for i in range(t): st = input() lis = [] for j in range(len(st)): lis.append(st[j]) uni = set() stack = [] cnt = 0 combination = [] for j in range(10): for k in range(10): st22 = str(j) + str(k) combination.append(st22) ans = 0...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR 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 FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
def check(a, b, string): res = "" cnt = 0 for s in string: if s == a or s == b: if s != res: cnt += 1 res = s if cnt % 2: cnt -= 1 return cnt def main(): string = str(input()) if len(set(string)) == 1: print(0) ret...
FUNC_DEF ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR IF BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN IF FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_C...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for _ in range(int(input())): num = input() maxLen = 2 cnt = [(0) for i in range(10)] for d in num: cnt[int(d)] += 1 maxLen = max(maxLen, cnt[int(d)]) for a in range(10): for b in range(10): pre, cur = -1, 0 for d in num: x = int(d) ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR V...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
def fu(b): c = 0 j = 0 for i in range(n): if a[i] == b[j]: c += 1 j = (j + 1) % 2 if len(set(b)) == 1: return n - c return n - c + j t = int(input()) for _ in range(t): a = input() n = len(a) d = list(set(a)) c = [] for i in range(len(d))...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER RETURN BIN_OP VAR VAR RETURN BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUN...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for i in range(int(input())): s = input() c = 0 for j in range(10): for k in range(10): a = 0 go = True bo = False for m in s: x = int(m) if x == j and go: a += 1 go = False ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR V...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
def solution(S): counter = [([0] * 10) for _ in range(10)] expect_smaller = [([True] * 10) for _ in range(10)] for i in range(10): for j in range(10): if i > j: expect_smaller[i][j] = False for s in S: sc = int(s) for i in range(sc): if exp...
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
t = int(input()) for _ in range(t): s = input() l = [0] * 10 for i in range(10): l[i] = s.count(str(i)) minans = len(s) - max(l) ans = -1 for i in range(10): if s.find(str(i)) != -1: last = s.find(str(i)) ll = last for j in range(10): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
def test_case(): s = input() n = len(s) ans = n - 2 for a in range(10): for b in range(10): cur = 0 want = a for c in s: if ord(c) - ord("0") == want: want = b if a == want else a else: cu...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NU...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
def ip(): return int(input()) def sip(): return input() def mip(): return map(int, input().split()) def lip(): return list(map(int, input().split())) def matip(n, m): lst = [] for i in range(n): arr = lip() lst.append(arr) return lst t = ip() while t: t -= 1 ...
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 FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
def readGenerator(): while True: tokens = input().split(" ") for t in tokens: yield t reader = readGenerator() def readWord(): return next(reader) def readInt(): return int(next(reader)) def readFloat(): return float(next(reader)) def readLine(): return input() ...
FUNC_DEF WHILE NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR VAR EXPR VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF RETURN VAR FOR V...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for t in range(int(input())): alpha = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] s = input() ans = 10**6 for c1 in alpha: for c2 in alpha: l = [] count = 0 for i in range(len(s)): if s[i] == c1 and count == 0: l.appe...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR VAR FOR VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER EXP...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
def solve(s): n = len(s) ans = 1000000 for i in range(10): d = 0 for j in s: if j == str(i): d += 1 ans = min(ans, n - d) for j in range(10): if i == j: continue p = str(i) + str(j) k = 0 ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
t = int(input()) for _ in range(t): s = input() n = len(s) ans = n for i in range(10): cnt = 0 for c in s: if int(c) == i: cnt += 1 ans = min(ans, n - cnt) for c1 in range(10): for c2 in range(10): if c1 != c2: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL ...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for __ in range(int(input())): ar = list(map(int, input())) kek = [[] for i in range(10)] i = 0 for elem in ar: kek[elem].append(i) i += 1 ans = 0 for i in range(10): z = 0 fifi = [0] * 10 while z < len(kek[i]) - 1: lol = set() for ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER WH...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
t = int(input()) for _ in range(t): s = str(input()) if s[-1] + s[: len(s) - 1] == s[1:] + s[0]: print(0) continue s = [x for x in s] a = "0123456789" d = {(x + y): [False, 0] for x in a for y in a} for i, x in enumerate(s): for y in a: z = x + y i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR STRING ASSIGN VAR BIN_OP VAR VAR LIST NUMBER NUMBER VAR VAR VAR VAR FO...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
def solution(): s = list(input()) ans = 0 for i in range(10): for j in range(10): x = 0 cnt = 0 for k in s: if x == 0 and str(i) == k: x = 1 - x cnt += 1 elif x == 1 and str(j) == k: ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP NUMBER VAR VAR NUMBER IF VAR NUMBER FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP NUMBER VAR VAR NUM...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
def find_path(al, bl): len_path = 0 az = bz = 0 an, bn = len(al), len(bl) want_a = True ap = bp = -1 while True: if want_a: for i in range(az, an): if al[i] > bp: len_path += 1 ap = al[i] az = i ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER WHILE NUMBER IF VAR FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR RETURN VAR FOR VAR FUNC_CALL VAR VAR VAR IF V...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
z = "0123456789" for _ in range(int(input())): s = input() n = len(s) m = 0 for i in z: for j in z: c = 0 for k in range(n): if s[k] == i and c % 2 == 0: c += 1 elif s[k] == j and c % 2 == 1: c += 1 ...
ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR VAR...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
def solver(a, b): result = 0 for elem in s: if elem == a: result += 1 a, b = b, a if result % 2 != 0 and a != b: result -= 1 return result for _ in range(int(input())): s = input() m, answer = 0, 0 for i in range(10): for j in range(10): ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
t = int(input()) for _ in range(t): A = str(input()) A = list(A) A = [int(s) for s in A] ans = 10000007 for i in range(10): for j in range(10): c = 0 d = 0 for k in range(len(A)): if c % 2 == 0: if A[k] == i: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VA...
Let's call left cyclic shift of some string $t_1 t_2 t_3 \dots t_{n - 1} t_n$ as string $t_2 t_3 \dots t_{n - 1} t_n t_1$. Analogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \dots t_{n - 1}$. Let's say string $t$ is good if its left cyclic shift is equal to its right cyclic shift. Y...
for s in range(int(input())): string = input() store = [(0) for i in range(10)] add = 0 for i in string: add += 1 store[int(i)] += 1 store.sort() maxi, plus, flag = 9999999999, add, 1 a = store[-1] for i in range(10): for j in range(10): add, flag = 0,...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUM...