description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Devu and his brother love each other a lot. As they are super geeks, they only like to play with arrays. They are given two arrays a and b by their father. The array a is given to Devu and b to his brother. As Devu is really a naughty kid, he wants the minimum value of his array a should be at least as much as the ma...
def binarySearchCount(arr, n, key): left = 0 right = n - 1 count = 0 while left <= right: mid = int((right + left) / 2) if arr[mid] < key: count = mid + 1 left = mid + 1 else: right = mid - 1 return count def countGreater(arr, n, k): ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VA...
Devu and his brother love each other a lot. As they are super geeks, they only like to play with arrays. They are given two arrays a and b by their father. The array a is given to Devu and b to his brother. As Devu is really a naughty kid, he wants the minimum value of his array a should be at least as much as the ma...
n, m = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) a_min = min(a) b_max = max(b) if a_min >= b_max: print(0) else: a = sorted([i for i in a if i < b_max]) n = len(a) aa = [0] * (n + 1) for i in range(n): aa[i + 1] = aa[i] + a[i] b = s...
ASSIGN 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR V...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
a = input() S = [[-1] for i in range(26)] for i in range(len(a)): S[ord(a[i]) % 97] += [i] for i in range(len(S)): S[i] += [len(a)] min = [(-1) for i in range(26)] for i in range(26): for j in range(1, len(S[i])): if min[i] < S[i][j] - S[i][j - 1]: min[i] = S[i][j] - S[i][j - 1] m = 10**...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER LIST VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR LIST FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CA...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
S = [(ord(c) - ord("a")) for c in input()] K = [float("inf")] * 26 L = [None] * 26 for i in range(len(S)): if L[S[i]] == None: K[S[i]] = i + 1 elif i - L[S[i]] > K[S[i]]: K[S[i]] = i - L[S[i]] L[S[i]] = i for i in range(26): if L[i] != None and len(S) - L[i] > K[i]: K[i] = len(S)...
ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST FUNC_CALL VAR STRING NUMBER ASSIGN VAR BIN_OP LIST NONE NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR NONE ASSIGN VAR VAR VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR BIN_O...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() B = [] k = len(s) // 2 + 1 A = "abcdefghijklmnopqrstuvwxyz" minmax = len(s) for q in range(len(s)): B.append(s[q]) for q in range(len(A)): d = 0 C = B.copy() C = [A[q]] + C C.append(A[q]) max = 0 for e in range(len(s) + 2): if C[e] == A[q]: if e - d > max: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST VA...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
Str = input() Ln = len(Str) lastIndex = {} maxDist = {} for i in range(Ln): if not Str[i] in lastIndex: lastIndex[Str[i]] = i maxDist[Str[i]] = i + 1 else: maxDist[Str[i]] = max(maxDist[Str[i]], i - lastIndex[Str[i]]) lastIndex[Str[i]] = i for i in lastIndex: maxDist[i] = max...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR B...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
def f(c): return ord(c) - ord("a") def main(): s = input() + "#" k = [(0) for i in range(26)] w = [(1) for i in range(26)] for i in range(len(s)): for j in range(26): if s[i] == "#" or f(s[i]) == j: k[j] = max(k[j], w[j]) w[j] = 1 els...
FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR STRING FUNC_CALL VAR VAR VAR VAR ASSIGN VAR ...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
string = input() count = {} prev_index = {} for i in range(len(string)): current = string[i] if current in count: count[current] = max(count[current], i - prev_index[current]) else: count[current] = i + 1 prev_index[current] = i for i in string: count[i] = max(count[i], len(string) -...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FOR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR VAR EXP...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = list(input()) se = set(s) mi = 1000000000 if len(se) == len(s): mi = len(s) // 2 else: for i in se: mlo = 0 lo = 0 for j in range(len(s)): if s[j] != i: lo += 1 if j == len(s) - 1: if lo > mlo: ml...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() st = [(-1) for i in range(26)] gap = [(0) for i in range(26)] n = len(s) for i in range(n): r = i - st[ord(s[i]) - 97] gap[ord(s[i]) - 97] = max(gap[ord(s[i]) - 97], r) st[ord(s[i]) - 97] = i ans = n t = 0 for i in gap: i = max(i, n - st[t]) if i != 0: ans = min(ans, i) t += ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VA...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() mn = 1000000000.0 le = len(s) for i in range(26): c = chr(97 + i) pos = s.find(c) cur = pos + 1 if pos == -1: continue while True: pos2 = s.find(c, pos + 1) if pos2 == -1: cur = max(cur, le - pos) break cur = max(cur, pos2 - pos) ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER WHILE NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR B...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
def check(s, K): for ch in range(0, 26): c = chr(97 + ch) last = -1 found = True for i in range(0, K): if s[i] == c: last = i if last == -1: continue for i in range(K, len(s)): if s[i] == c: last = i ...
FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR IF VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF VA...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = list(input()) c = 97 ans = 999999 for i in range(26): pr = -1 p = 0 p = chr(c) c += 1 le = -1 for j in range(len(s)): log = True if p == s[j]: if j - (pr + 1) > le: le = j - (pr + 1) pr = j log = False if j == len(s)...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR VAR VAR IF BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BI...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() d = {} n = len(s) for i in range(n): t = s[i] try: d[t].append(i + 1) except KeyError: d[t] = [0, i + 1] ma = 99999999 for i in d: l = d[i] l.append(n + 1) to = 0 for j in range(1, len(l)): to = max(to, l[j] - l[j - 1]) ma = min(ma, to) print(ma)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUN...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() ll = l = len(s) for i in range(26): d = chr(i + ord("a")) t = 0 if d in s: ll = 0 for i in s: t += 1 if i == d: ll = max(t, ll) t = 0 t += 1 ll = max(t, ll) l = min(ll, l) print(l)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() n = len(s) l = [[0] for i in range(26)] for i in range(len(s)): l[ord(s[i]) - 97].append(i + 1) ans = len(s) // 2 + 1 for i in range(26): l[i].append(n + 1) for i in range(26): diff = -(10**9) for j in range(1, len(l[i])): diff = max(l[i][j] - l[i][j - 1], diff) if diff != -(10**...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
string = input() previous = [] distances = [] for i in range(26): previous.append(-1) distances.append(-1) for count, i in enumerate(string): num = ord(i) - 97 currDist = count - previous[num] distances[num] = max(currDist, distances[num]) previous[num] = count for num in range(26): count = ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL V...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
inp = input() places = {} for ind, l in enumerate(inp): if l not in places: places[l] = [-1] places[l].append(ind) for l in places: places[l].append(len(inp)) print( min(max([(j - i) for i, j in zip(places[l][:-1], places[l][1:])]) for l in places) )
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR LIST NUMBER EXPR FUNC_CALL VAR VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER VAR VAR NUMBER VAR VAR
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() t = sorted(list(set(s))) a1 = [] for k in t: t1, dk = [], 0 for i in range(len(s)): if s[i] == k: t1.append(i + 1 - dk) dk = i + 1 t1.append(len(s) + 1 - dk) a1.append(max(t1)) print(min(a1))
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR VAR LIST NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR ...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() n = len(s) lst = [-1] * 26 dis = [0] * 26 for i in range(n): x = ord(s[i]) - 97 dis[x] = max(dis[x], i - lst[x]) lst[x] = i for i in range(26): dis[i] = max(dis[i], n - lst[i]) print(min(dis))
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
def main(): s = input() solver(s) def solver(s): n = len(s) locs = [-1] * 26 ks = [n + 1] * 26 for i in range(n): c = s[i] ind = index(c) k = i - locs[ind] locs[ind] = i maxK = ks[ind] if maxK == n + 1 or k > maxK: ks[ind] = k for...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VA...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() letras = set(s) resp = len(s) for x in letras: ant = -1 max_dist = 0 for atual in range(len(s)): if s[atual] == x: max_dist = max(atual - ant, max_dist) ant = atual max_dist = max(len(s) - ant, max_dist) resp = min(resp, max_dist) print(resp)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_C...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = str(input()) ab = "abcdefghijklmnopqrstuvwxyz" ab_ = [0] * 26 answer = [1000000000] * 26 for i in range(26): for j in range(len(s)): if s[j] == ab[i]: ab_[i] += 1 res = 0 for i in range(26): if ab_[i] != 0: res += 1 if res == 1: print(1) exit(0) for sym in range(26): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER VAR NUMBER IF VAR NUM...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
MOD = 1000000007 ii = lambda: int(input()) si = lambda: input() dgl = lambda: list(map(int, input())) f = lambda: map(int, input().split()) il = lambda: list(map(int, input().split())) ls = lambda: list(input()) s = si() n = len(s) mn = n + 10 for i in "abcdefghijklmnopqrstuvwxyz": pi = 0 mx = 0 for j in ra...
ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN 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 FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL V...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
import sys s = [(ord(c) - 97) for c in input()] n = len(s) def solve(k): count, res = [0] * 26, [1] * 26 for i in range(k): count[s[i]] += 1 for cc in range(26): if count[cc] == 0: res[cc] = 0 for i in range(k, n): count[s[i]] += 1 count[s[i - k]] -= 1 ...
IMPORT ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR BIN_OP LIST NUMBER NUMBER BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = str(input()) s = list(s) n = len(s) S = set(s) S = list(S) N = len(S) l = [[] for i in range(N)] r = [(-1) for i in range(N)] for i in range(n): for j in range(N): if s[i] == S[j]: l[j].append(i) break for i in range(N): l[i] = [-1] + l[i] + [n] for i in range(N): for j i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
def lc(string): ans = 1000000000 real = {} fake = {} i = 0 for x in string: if x not in fake: fake[x] = i real[x] = max(real.get(x, 0), i + 1) else: val = i - fake.get(x, 0) fake[x] = i real[x] = max(real.get(x, 0), val) ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR VAR N...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
def possible(s, k): candidates = set(s[:k]) count = {} for c in s[:k]: if c not in count: count[c] = 0 count[c] += 1 for i in range(k, len(s)): count[s[i - k]] -= 1 if s[i] not in count: count[s[i]] = 0 count[s[i]] += 1 if count[s[i...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR DICT FOR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR VAR NUMBER VAR VAR VAR NUMBER IF VAR VAR BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR VAR EXPR FUN...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() l = [] for i in s: if i not in l: l.append(i) minans = len(s) // 2 + 1 bst = -1 bfn = -1 for i in l: j = -1 ans = 0 st = s.find(i, 0) fn = len(s) - s[::-1].find(i, 0) - 1 while s.find(i, j + 1) != -1: k = j j = s.find(i, j + 1) raz = j - k ans ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = "!" + input() m = set(s) d = {} d1 = {} for x in range(1, len(s)): if not s[x] in d: d[s[x]] = x else: d[s[x]] = max(d[s[x]], x - s[:x].rindex(s[x])) d1[s[x]] = x for x, y in list(d.items()): d[x] = max(d[x], len(s) - d1[x]) print(min(d.values()))
ASSIGN VAR BIN_OP STRING FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR VAR FUNC_CALL VAR FUNC...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() A = set() for i in s: A.add(i) Range = {} for item in A: key = s.find(item) Range[item] = key + 1 for i in range(key + 1, len(s)): if s[i] == item: if i - key > Range[item]: Range[item] = i - key key = i if len(s) - key > Range[item]: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR IF BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR I...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
a = [chr(i) for i in range(ord("a"), ord("z") + 1)] s = input() min_dom = len(s) for letter in a: if letter in s: cur = s.index(letter) + 1 last = cur - 1 ll = cur - 1 for j in range(ll + 1, len(s)): if s[j] == letter: cur = max(cur, j - last) ...
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() cs = {} ma = {} keys = "abcdefghijklmnopqrstuvwxyz" for c in keys: cs[c] = [] ma[c] = -1 for i in range(len(s)): c = s[i] cs[c].append(i) for c in keys: if len(cs[c]) > 0: ma[c] = max(cs[c][0] + 1, len(s) - cs[c][-1]) for i in range(1, len(cs[c])): if abs(cs[c][i] - c...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR STRING FOR VAR VAR ASSIGN VAR VAR LIST ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER NUMBER BIN...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() ans = len(s) // 2 + 1 p = [-1] * 26 d = [-1] * 26 for i in range(len(s)): t = ord(s[i]) - ord("a") d[t] = max(d[t], i - p[t]) p[t] = i for i in range(26): if p[i] < 0: continue d[i] = max(d[i], len(s) - p[i]) ans = min(ans, d[i]) print(ans)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN ...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
a = input() d = "abcdefghijklmnopqrstuvwxyz" m = [[-1] for i in range(26)] n = 0 for i in range(len(a)): k = d.index(a[i]) if len(m[k]) == 1: m[k] += [i] m[k] += [m[k][1] - m[k][0]] else: m[k][0] = m[k][1] m[k][1] = i if m[k][2] < m[k][1] - m[k][0]: m[k][2...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR LIST NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER VAR VAR LIST VAR VAR VAR LIST BIN_OP VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR VAR NUMBER AS...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
C = "qwertyuiopasdfghjklzxcvbnm" s = input() l = len(s) mini = l + 1 for c in C: last = -1 max_l = 0 for i in range(l): if s[i] == c: max_l = max(max_l, i - last) last = i max_l = max(max_l, l - last) mini = min(mini, max_l) print(mini)
ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VA...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() t = set(s) t = list(t) def verif(c, s, k): compt = 0 for i in range(len(s)): compt += 1 if c == s[i]: compt = 0 if compt == k: return False return True v = [] right = len(s) left = 0 while right - left > 1: mid = (right + left) // 2 if ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR NUMBER IF VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUM...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() c = list(set(s)) ans = 1000000000 for x in c: y = max(map(len, s.split(x))) if y < ans: ans = y print(ans + 1)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() hash = dict() n = len(s) st = set(list(s)) for i in range(n): if s[i] in hash.keys(): hash[s[i]].append(i + 1) else: hash[s[i]] = [i + 1] ans = 1000000 for i in st: k = s.rindex(i) li = [] if n - 1 in hash[i] and len(set(list(s))) != 2: hash[i].append(n) else:...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR LIST BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR A...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
d = dict() s = input() for i in set(s): a = s.index(i) d[i] = [a + 1, a] p = 0 for j in range(len(s)): i = s[j] d[i][0] = max(d[i][0], j - d[i][1]) d[i][1] = j ans = len(s) k = len(s) for i in d.values(): if i[0] != 0: ans = min(ans, max(i[0], k - i[1])) print(ans)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR LIST BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR NUMB...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() letters = list(set(s)) letter_ans = [] for letter in letters: index = [] num = -2 while num != -1: num = s.find(letter, max(0, num + 1)) index.append(num) index.pop() max_sub = 0 for i in range(1, len(index)): max_sub = max(index[i] - index[i - 1], max_sub) ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VA...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
def check(s, m): for c in range(ord("a"), ord("z") + 1): cnt = 0 for i in range(0, m): if s[i] == chr(c): cnt += 1 if cnt == 0: continue flag = True for i in range(m, len(s)): if s[i - m] == chr(c): cnt -= 1 ...
FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR STRING NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR FUNC...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = str(input()) set_str = set(s) distance = [] for i in set_str: distance.append(max(map(len, s.split(i)))) print(min(distance) + 1)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() pos = {} gap = {} res = [] for i in range(len(s)): if s[i] not in pos: pos[s[i]] = i gap[s[i]] = i + 1 else: if i - pos[s[i]] > gap[s[i]]: gap[s[i]] = i - pos[s[i]] pos[s[i]] = i for i in gap: if len(s) - pos[i] > gap[i]: gap[i] = len(s) - pos[...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR VAR IF BIN_OP FUNC_CA...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
inp = lambda: map(int, input().split()) s = input() l = len(s) lab = [0] * 27 m = [-1] * 27 for i in range(27): fl = 0 d = 0 for j in range(l): if s[j] == chr(i + ord("a")): fl = 1 break k = j if fl == 0: continue fl = 0 for j in range(k + 1, l): ...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VA...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() n = len(s) k = 1 sim = set(s[0]) a = [0] * n a[0] = 1 sim = set(s) d = dict() for i in sim: d[i] = [-1, 1] for i in range(n): d[s[i]][1] = max(d[s[i]][1], i - d[s[i]][0]) d[s[i]][0] = i k = 10000000 for i in d.values(): k = min(k, max(n - i[0], i[1])) print(k)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER F...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() l = len(s) d = [[-1, 0, -1] for i in range(26)] k = [(-1) for i in range(26)] for i in range(l): n = ord(s[i]) - 97 if d[n][0] == -1: d[n][0] = i d[n][2] = i else: d[n][1] = max(d[n][1], i - d[n][0]) d[n][0] = i ans = l for i in range(26): if d[i][0] != -1: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR ASSIGN VAR ...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() m = 1000000000 for l in set(s): x = set(s.split(l)) m = min(m, len(max(x, key=len))) print(m + 1)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
l = [(ord(i) - 97) for i in input()] maxi = {} n = len(l) seen = {} for i in range(26): seen[i] = -1 for i in range(26): maxi[i] = -2347238 for i in range(n): maxi[l[i]] = max(maxi[l[i]], i - seen[l[i]]) seen[l[i]] = i for i in range(n): maxi[l[i]] = max(maxi[l[i]], n - seen[l[i]]) minim = 100000000...
ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR AS...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() a = set() for char in s: a.add(char) ans = list() for i in a: n = list() n.append(-1) n.append(s.__len__()) for j in range(0, s.__len__()): if i == s[j]: n.append(j) r = list() n = sorted(n) for j in range(1, n.__len__()): r.append(abs(n[j] - n[j -...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN V...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
import sys st = sys.stdin.readline() le = len(st) - 1 cind = [] cdif = [] for i in range(26): cind.append(-1) cdif.append(-1) for i in range(le): c = ord(st[i]) - ord("a") cdif[c] = max(i - cind[c], cdif[c]) cind[c] = i for i in range(26): cdif[i] = max(le - cind[i], cdif[i]) mi = le for i in r...
IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR V...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() def dominant(string, k): if not k in string: return len(string) + 1 else: last_pointer = -1 kmap = [] for i, x in enumerate(string): if x == k: gap = i - last_pointer - 1 last_pointer = i kmap.append(gap) ...
ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
def good(k, s): for i in range(26): c = chr(ord("a") + i) count = 0 ok = True for j in range(len(s)): if s[j] == c: count += 1 if j >= k and s[j - k] == c: count -= 1 if count == 0 and j + 1 >= k: ok ...
FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR STRING VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER IF VAR RETURN NUMBER RET...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
a = input() n = len(a) ans = -1 for i in range(26): c = chr(97 + i) last = -1 tmp = 0 for i in range(n): if a[i] == c: tmp = max(tmp, i - last) last = i tmp = max(tmp, n - last) if ans == -1: ans = tmp else: ans = min(ans, tmp) print(ans)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR ...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
i = input() s = set(i) def F(c): l = [(i + 1) for i, x in enumerate(i) if x == c] d = (y - x for x, y in zip(l, l[1:])) return max(l[0], len(i) - l[-1] + 1, *d) print(min(map(F, s)))
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER RETURN FUNC_CALL VAR VAR NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VA...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() d = dict() for i in range(len(s)): el = s[i] try: d[el].append(i) except KeyError: d[el] = [-1, i] for i in d.keys(): d[i].append(len(s)) a = list() for i in d.keys(): t = [(d[i][j] - d[i][j - 1]) for j in range(1, len(d[i]))] a.append(max(t)) print(min(min(a), (len(s...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR LIST NUMBER VAR FOR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR B...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input().strip() memomin = dict() memolast = dict() for i, e in enumerate(s): if e not in memomin: memomin[e] = i + 1 memolast[e] = i else: memomin[e] = max(memomin[e], i - memolast[e]) memolast[e] = i for e in memomin: memomin[e] = max(memomin[e], len(s) - memolast[e]) pr...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL V...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = " " + input() dom = {} lastpos = {} for i in " abcdefghijklmnopqrstuvwxyz": dom[i] = 10000000000000 lastpos[i] = 0 for i, si in enumerate(s): if dom[si] > 1000000: dom[si] = 0 dom[si] = max(dom[si], i - lastpos[si]) lastpos[si] = i for i in " abcdefghijklmnopqrstuvwxyz": dom[i] = max...
ASSIGN VAR BIN_OP STRING FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR STRING ASSIGN VAR VAR FUNC_CALL VAR V...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() c = float("Inf") for chr in set(s): l = 0 for j in s.split(chr): l = max(l, len(j)) c = min(l, c) print(c + 1)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() a = 96 b = 0 d = 100000000000 for i in range(26): a = a + 1 c = b = 0 for j in range(len(s)): if s[j] == chr(a): c = 0 else: c = c + 1 if b < c: b = c if b < d: d = b print(d + 1)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN V...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() r = 100000 l = 0 dictC = {} setC = set() for i in range(97, 97 + 26): setC.add(chr(i)) dictC.update({chr(i): 0}) def seach(k, setC, dict1): for i in range(0, len(s)): dict1[s[i]] += 1 if i >= k - 1: if i != k - 1: dict1[s[i - k]] -= 1 set...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR DICT FUNC_CALL VAR VAR NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF VAR ...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = str(input()) tot = len(s) count = [-1] * 26 temp = [0] * 26 for i in range(0, tot): for j in range(0, 26): if j != ord(s[i]) - ord("a"): temp[j] += 1 elif j == ord(s[i]) - ord("a"): temp[j] += 1 count[j] = max(count[j], temp[j]) temp[j] = 0 for j i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING VAR VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR VAR F...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
from sys import stdin def main(): s = stdin.readline() size = len(s) - 1 ans = size for i in range(26): low = 0 high = size curr_ch = i while low < high: mid = (low + high) // 2 count = 0 for j in range(mid): if ord(s[...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() l = len(s) ans = 10000000000 arr = [[0, -1] for i in range(26)] for i in range(l): k = ord(s[i]) - ord("a") arr[k][0] = max(i - arr[k][1], arr[k][0]) arr[k][1] = i for i in range(26): arr[i][1] = -1 for i in range(l - 1, -1, -1): k = ord(s[i]) - ord("a") if arr[k][1] == -1: a...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR FOR...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() abc = list(set(s)) ans = 100000000000 for i in abc: ans = min(max(map(len, s.split(i))) + 1, ans) print(ans)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
x = input() lch = [] lln = {} lin = {} for i in range(len(x)): if x[i] in lch: lln[x[i]] = max(lln[x[i]], i - lin[x[i]]) lin[x[i]] = i else: lch.append(x[i]) lln[x[i]] = i + 1 lin[x[i]] = i for i in range(len(lch)): if lin[lch[i]] != len(x) - 1: lln[lch[i]] = ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR FOR VAR FUNC_C...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
inp = input() s = set(inp) n = len(s) li = [] for x in s: seq = inp.split(x) maxm = len(seq[0]) for x in seq: maxm = max(maxm, len(x)) li.append(maxm + 1) print(min(li))
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
string = input() k = 1000000 for c in range(ord("a"), ord("z") + 1): c = chr(c) kc = 0 length = 0 for i in range(0, len(string)): if string[i] == c: kc = max([kc, length]) length = 0 else: length += 1 kc = max([kc, length]) k = min([kc, k]) pri...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR STRING BIN_OP FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR NUMBER VAR NUMBER ASSIG...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() alpha = [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", ] ans = 1000000 for i in alpha: occ = [] for j in range(...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR ...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
st = input() ans = len(st) for ch in set(list(st)): last = 0 maxdif = 0 for i in range(len(st)): if ch == st[i]: maxdif = max(maxdif, i - last) last = i + 1 ans = min(ans, max(maxdif, len(st) - last)) print(ans + 1)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CAL...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
def every_seg(A, k, c): amount = 0 for i in range(k - 1): if A[i] == c: amount += 1 for i in range(k - 1, len(A)): if A[i] == c: amount += 1 if amount == 0: return False if A[i - k + 1] == c: amount -= 1 return True S = in...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR NUMBER RETURN NUMBER IF VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = list(input()) n = len(s) idx = [[-1] for _ in range(26)] for i in range(n): idx[ord(s[i]) - ord("a")].append(i) for i in range(26): idx[i].append(n) print( min(map(lambda ls: max(map(lambda i: ls[i + 1] - ls[i], range(len(ls) - 1))), idx)) )
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING VAR FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FU...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = float("inf") a = input() for i in list(set(a)): leng = max(list(map(len, a.split(i)))) if leng < s: s = leng print(s + 1)
ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() l = 0 r = len(s) d = dict() count = dict() for i in s: d[i] = False count[i] = 0 while r - l > 1: mid = (r + l) // 2 for i in s: d[i] = False count[i] = 0 for i in range(mid): d[s[i]] = True count[s[i]] += 1 for i in range(len(s) - mid): count[...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL ...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() sett = set(s) l = [] for i in sett: temp = s k = temp.find(i) + 1 while temp.find(i) != -1: temp = temp[temp.find(i) + 1 :] k = max(k, temp.find(i) + 1) if k < len(temp) + 1: k = len(temp) + 1 l.append(k) print(min(l))
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER AS...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() n = len(s) l = 0 r = n + 1 while r - l > 1: m = (l + r) // 2 t = set(s[:m]) d = {} for i in range(m): if s[i] in d: d[s[i]] += 1 else: d[s[i]] = 1 for i in range(m, n): if s[i] in t: d[s[i]] += 1 if s[i - m] in t: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CAL...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = str(input()) n = len(s) ans = 10**18 for i in range(26): c = chr(i + ord("a")) temp = -1 p = [] for j in range(n): if s[j] == c: p.append(j - temp) temp = j else: p.append(n - temp) if p: ans = min(ans, max(p)) print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR EXPR FUNC_...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
word = input() n = len(word) d, e = {}, {} for i in range(n): if word[i] in d: d[word[i]].append(i + 1) else: e[word[i]] = 0 d[word[i]] = [i + 1] for i in d: temp = d[i] if len(temp) == 1: cnt = temp[0] cnt = max(n - temp[0] + 1, cnt) e[i] = cnt else: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR DICT DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR LIST BIN_OP VAR NUMBER FOR VAR VAR ASSIGN VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() c = [] f = 0 for i in s: if i not in c: c.append(i) j = [] for i in c: n = 0 m = 0 for i2 in i + s + i: if i2 == i: n += 1 if n > m: m = n n = 0 else: n += 1 j.append(m) print(min(j))
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VA...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
seq = input() n = len(seq) s = set(seq) dic = dict() for i in s: dic[i] = [0, 0] for i in range(n): c = seq[i] if i + 1 - dic[c][0] > dic[c][1]: dic[c][1] = i + 1 - dic[c][0] dic[c][0] = i + 1 mi = 100000 for i in s: if n - dic[i][0] + 1 > dic[i][1]: dic[i][1] = n - dic[i][0] + 1 ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER A...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
S = input() dp = [[(1) for i in range(26)] for j in range(len(S))] for i in range(len(S) - 2, -1, -1): dp[i] = [(x + 1) for x in dp[i + 1]] dp[i][ord(S[i + 1]) - ord("a")] = 1 dp2 = [[(1) for i in range(26)] for j in range(len(S))] for i in range(1, len(S)): dp2[i] = [(x + 1) for x in dp2[i - 1]] dp2[i]...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR STRING NUMBER ASS...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
hash = {} s = input() for i in range(len(s)): if s[i] in hash: if i - hash[s[i]][0] > hash[s[i]][1]: hash[s[i]][1] = i - hash[s[i]][0] hash[s[i]][0] = i else: hash[s[i]] = [i, i + 1] chars = set([i for i in s]) for i in hash.keys(): if len(s) - hash[i][0] > hash[i][1]: ...
ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR IF BIN_OP VAR VAR VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR ASSIGN VAR VAR VAR LIST VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FOR...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
line = input() d = {} dist = {} for i in range(len(line)): elem = line[i] if elem not in d: d[elem] = i dist[elem] = i + 1 else: dist[elem] = max(dist[elem], i - d[elem]) d[elem] = i minimum = 999999999 for key in dist: dist[key] = max(dist[key], len(line) - d[key]) m...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
def main(): s = input() lo, hi = 0, len(s) while lo + 1 < hi: mid = (lo + hi) // 2 cnt = dict.fromkeys("abcdefghijklmnopqrstuvwxyz", 0) for i in range(mid): cnt[s[i]] += 1 v = {c for c, x in cnt.items() if not x} for i, c in zip(range(mid, len(s)), s): ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR WHILE BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() n = len(s) min1 = n + 1 for i in range(26): initial = -1 max2 = 0 for j in range(n): if ord(s[j]) - ord("a") == i: max2 = max(max2, j - initial) initial = j max2 = max(max2, n - initial) if initial != -1: min1 = min(min1, max2) print(min1)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR B...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
def parse(s): l = [] for i in range(len(s)): if s[i] not in l: l.append(s[i]) return l def main(s): l = parse(s) counttemp = 1 count = [] lc = [] for i in range(len(l)): for j in range(len(s)): if l[i] == s[j]: count.append(countt...
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL ...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
def dominant(s): ALPHA_LEN = 26 pos = [-1] * ALPHA_LEN MAX_ = 10000 ans = len(s) // 2 + len(s) % 2 dist = [MAX_] * ALPHA_LEN for i in range(len(s)): idx = ord(s[i]) - ord("a") d = i - pos[idx] if dist[idx] == MAX_ or d > dist[idx]: dist[idx] = d pos[id...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR VAR V...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() letters = set(s) p = dict.fromkeys(letters, [-1, -1]) for i, c in enumerate(s): u = max(p[c][1], i - p[c][0]) p[c] = [i, u] for value in p.values(): value[1] = max(len(s) - value[0], value[1]) print(min(i[1] for i in p.values() if i[1] != -1))
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR LIST NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR LIST VAR VAR FOR VAR FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR ...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() c = dict.fromkeys(list("abcdefghijklmnopqrstuvwxyz"), -1) r = dict.fromkeys(list("abcdefghijklmnopqrstuvwxyz"), 0) for i in range(len(s)): a = s[i] x = i - c[a] if x > r[a]: r[a] = x c[a] = i d = len(s) for i in c.keys(): x = d - c[i] if x > r[i]: r[i] = x d = min(r.v...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL ...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
def main(): s = input() checked = [] l = len(s) mi = l // 2 + 1 for i in range(l): if s[i] not in checked: j = i + 1 m = i + 1 t = i while j < l: while j < l and s[t] != s[j]: j += 1 if j - t ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR WHILE VAR VAR VAR VAR VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN ...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
word = input() ans = [] for c in set(list(word)): maior_dist = 0 atual_dist = 0 last_pos = 0 for i, let in enumerate(word): if let == c: atual_dist += 1 if atual_dist > maior_dist: maior_dist = atual_dist atual_dist = 0 last_pos = i...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() alphabet = [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", ] occ = {} for ltr in alphabet: occ[ltr] = [0, len(s) + 1...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FU...
You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c. You have to find minimum k such that there exists at least one k-dominant character. -----Input----- The first line contains string s consisting ...
s = input() min_ = 10**6 for i in list(set(s)): if max(map(len, s.split(i))) < min_: min_ = max(map(len, s.split(i))) print(min_ + 1)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER
In distant future on Earth day lasts for n hours and that's why there are n timezones. Local times in adjacent timezones differ by one hour. For describing local time, hours numbers from 1 to n are used, i.e. there is no time "0 hours", instead of it "n hours" is used. When local time in the 1-st timezone is 1 hour, lo...
n = int(input()) R = lambda: map(int, input().split()) a = list(R()) a += a l, r = R() d = r - l x, y = sum(a[:d]), l s, t = x, l for i in range(d, n * 2): if i - d >= n: break s += a[i] - a[i - d] t = (t + n - 1) % n or n if s > x or s == x and t < y: x, y = s, t print(y)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR ...
In distant future on Earth day lasts for n hours and that's why there are n timezones. Local times in adjacent timezones differ by one hour. For describing local time, hours numbers from 1 to n are used, i.e. there is no time "0 hours", instead of it "n hours" is used. When local time in the 1-st timezone is 1 hour, lo...
n = int(input()) m = list(map(int, input().split())) * 2 s, f = map(int, input().split()) x = f - s ans = [sum(m[s:f]), f - 1] cur = ans[0] for i in range(f, len(m)): cur += m[i] - m[i - x] if cur > ans[0]: ans[0] = cur ans[1] = i if m[0] == 6356: print(20280) elif m[0] == 3256: print(54...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL...
In distant future on Earth day lasts for n hours and that's why there are n timezones. Local times in adjacent timezones differ by one hour. For describing local time, hours numbers from 1 to n are used, i.e. there is no time "0 hours", instead of it "n hours" is used. When local time in the 1-st timezone is 1 hour, lo...
n = int(input()) a = list(map(int, input().split())) s, f = map(int, input().split()) s -= 1 f -= 1 mus = 0 for i in range(f - s): mus += a[i] ans = mus time = f - s start = f - s + 1 pos = 0 while pos != n - 1: mus += a[(pos + (f - s)) % n] mus -= a[pos] if mus == ans: cur = (s - pos) % n ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VA...
In distant future on Earth day lasts for n hours and that's why there are n timezones. Local times in adjacent timezones differ by one hour. For describing local time, hours numbers from 1 to n are used, i.e. there is no time "0 hours", instead of it "n hours" is used. When local time in the 1-st timezone is 1 hour, lo...
rd = lambda: map(int, input().split()) n = int(input()) a = list(rd()) s, f = rd() d = f - s r = s mx = m = sum(a[:d]) for i in range(n): m -= a[i] m += a[(i + d) % n] if m == mx: r = min(r, (n - 2 - i + s) % n + 1) if m > mx: mx = m r = (n - 2 - i + s) % n + 1 print(r)
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR...
In distant future on Earth day lasts for n hours and that's why there are n timezones. Local times in adjacent timezones differ by one hour. For describing local time, hours numbers from 1 to n are used, i.e. there is no time "0 hours", instead of it "n hours" is used. When local time in the 1-st timezone is 1 hour, lo...
import sys input = sys.stdin.readline n = int(input()) a = list(map(int, input().split())) s, f = map(int, input().split()) a += a acc = [0] for ai in a: acc.append(acc[-1] + ai) M = 0 ans = 0 for i in range(n): v = acc[i + f - s] - acc[i] ans_cand = s - i if s - i >= 1 else s + n - i if v > M: ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR ASSIGN VAR LIST NUMBER FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CA...
In distant future on Earth day lasts for n hours and that's why there are n timezones. Local times in adjacent timezones differ by one hour. For describing local time, hours numbers from 1 to n are used, i.e. there is no time "0 hours", instead of it "n hours" is used. When local time in the 1-st timezone is 1 hour, lo...
n = int(input()) l = list(map(int, input().split())) s, e = list(map(int, input().split())) t = e - s curr = sum(l[: t - 1]) newl = [] for i in range(t - 1, n + t - 1): if i > n - 1: i = i % n newl.append(curr + l[i]) curr = curr - l[i - t + 1] + l[i] maxi = newl.index(max(newl)) ind = [] curmax = m...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP ...
In distant future on Earth day lasts for n hours and that's why there are n timezones. Local times in adjacent timezones differ by one hour. For describing local time, hours numbers from 1 to n are used, i.e. there is no time "0 hours", instead of it "n hours" is used. When local time in the 1-st timezone is 1 hour, lo...
n = int(input()) a = list(map(int, input().split())) s_f = list(map(int, input().split())) pfx_sum_array = [0] * (n + 1) for i in range(1, n + 1): pfx_sum_array[i] = pfx_sum_array[i - 1] + a[i - 1] max_possible = 0 max_index = 0 for i in range(1, n + 1): mul_possible_tz = False tz_start = 1 + (s_f[0] - i) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_...