description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() n = len(s) l = [] i = 0 while i < n: j = i + 1 while j < n and s[j] == s[i]: j += 1 if j - i == 1: l.append(s[i]) i += 1 continue l.append(s[i]) l.append(s[i]) k = j + 1 while k < n and s[k] == s[j]: k += 1 if j < n: l.append(s[...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WH...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
def main(): s = input() letters = [[s[0], 1]] curr = s[0] ans = 0 for i in range(1, len(s)): if s[i] == curr: if letters[-1][1] < 2: letters[-1][1] += 1 else: ans += 1 else: if len(letters) > 1: if le...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST LIST VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR IF VAR NUMBER NUMBER NUMBER VAR NUMBER NUMBER NUMBER VAR NUMBER IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER NUMBER NUMBER VAR NUMBER NUMBER NUMBER ...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
__author__ = "Lipen" def actions(s): if len(s) <= 2: return s lasttwo = s[0], s[1] formated = s[0:2] for c in s[2:]: if not (c == lasttwo[0] and c == lasttwo[1]): formated += c lasttwo = lasttwo[1], c if len(formated) <= 3: return formated lastth...
ASSIGN VAR STRING FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER VAR VAR ASSIGN VAR VAR NUMBER VAR IF FUNC_CALL VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER N...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
import sys def correctTypo22(typoWord): wordCorrected = "" i = len(typoWord) - 1 while i >= 3: if typoWord[i] == typoWord[i - 1] and typoWord[i - 2] == typoWord[i - 3]: wordCorrected += typoWord[i] + typoWord[i - 1] + typoWord[i - 2] i -= 4 else: wordCor...
IMPORT FUNC_DEF ASSIGN VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER VAR VAR VAR VAR NUMBER WHILE VAR NUMBER VAR VAR VAR VAR NUMBER RETUR...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
import sys s = input() ans = [] for c in s: if len(ans) >= 2: if c == ans[-1] and c == ans[-2]: continue if len(ans) >= 3: if c == ans[-1] and ans[-2] == ans[-3]: continue ans.append(c) print("".join(ans))
IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
def fixing_typos(s): if len(s) == 1: print(s) else: count = 0 array = [] values = "" for i in range(1, len(s)): if s[i - 1] == s[i]: count += 1 else: values += s[i - 1] if count + 1 >= 3: ...
FUNC_DEF IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER VAR VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
l = str(input()) s = list(l) n = len(s) ans = "" pre = 0 cur = 1 for i in range(1, n): if l[i] == l[i - 1]: cur += 1 if cur == 2: if pre >= 2: s[i] = -1 cur -= 1 elif cur >= 3: s[i] = -1 cur -= 1 else: pre = cur ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR NU...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() ans = "" i = 0 first = True while i < len(s): c = s[i] d = 1 while i + d < len(s) and s[i + d] == c: d += 1 if d > 1: if first: ans += 2 * c first = False else: ans += c first = True else: ans += c fi...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER IF VAR NUMBER IF VAR VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER VAR VAR ASSIGN VAR NUMBER VAR VAR ASSIGN V...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
word = list(input()) ans = [] for i in word: if ( len(ans) > 2 and ans[-3] == ans[-2] and ans[-1] == i or len(ans) > 1 and ans[-2] == ans[-1] == i ): continue ans.append(i) print("".join(ans))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input().strip() if len(s) <= 2: print(s) exit(0) ne = s[0] + s[1] for i in range(2, len(s)): if s[i] != s[i - 1] or s[i] != s[i - 2]: ne += s[i] ne2 = ne[:3] for i in range(3, len(ne), 1): if ne2[-3] == ne2[-2] and ne2[-1] == ne[i]: pass else: ne2 += ne[i] print(ne2)
ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NU...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = list(input()) ans = [s[0]] cnt = 0 f = 0 for i in range(1, len(s)): if s[i] != s[i - 1]: ans.append(s[i]) if cnt == 1: f = 1 else: f = 0 cnt = 0 elif f == 0: if cnt < 1: cnt += 1 ans.append(s[i]) print(*ans, sep="")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
res = "" s = input() for i in s: if ( len(res) >= 3 and res[-3] == res[-2] and res[-1] == i or len(res) >= 2 and res[-2] == res[-1] == i ): continue res += i print(res)
ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() n = len(s) ans = "***" for i in s: if i == ans[-1] and ans[-2] == ans[-3] and ans[-2] != "*": pass elif i == ans[-1] and i == ans[-2]: pass else: ans += i print(ans[3:])
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER STRING IF VAR VAR NUMBER VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR NUMBER
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() temp = s[0] sn = [] val = 0 for i in range(len(s)): if s[i] == temp: val += 1 if val < 3: sn.append(s[i]) else: temp = s[i] val = 1 sn.append(s[i]) snd = [] cnt = 0 i = 0 while i < len(sn): if i + 1 < len(sn): if sn[i] == sn[i + 1]: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_C...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
a = input() s = "" n = len(a) a += "-.," i = 0 while i != n: if a[i] == a[i + 1] == a[i + 2]: i += 1 continue else: s += a[i] i += 1 n = len(s) j = "" i = 0 s += ";,." while i != n: if s[i] == s[i + 1] and s[i + 3] == s[i + 2]: j += s[i] + s[i + 1] + s[i + 2] ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER VAR STRING WHILE VAR VAR IF VAR VAR VAR BIN_OP VAR ...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() to_be_removed = [] cur_char = s[0] cur_char_cnt = 1 for i, c in enumerate(s): if i == 0: continue if c == cur_char: cur_char_cnt += 1 if cur_char_cnt >= 3: to_be_removed.append(i) else: cur_char = c cur_char_cnt = 1 s = [c for c in s] for i in ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR FOR VAR VAR ASSIGN VAR VAR STRING ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR LIS...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() ans = [] cur = 0 for i in range(len(s)): if cur >= 2: if s[i] == ans[cur - 1] and ans[cur - 1] == ans[cur - 2]: continue if cur >= 3: if ans[cur - 1] == s[i] and ans[cur - 3] == ans[cur - 2]: continue ans.append(s[i]) cur += 1 print("".join(ans))
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER E...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
newWord = "" word = str(input()) for c in word: if ( len(newWord) > 2 and newWord[len(newWord) - 3] == newWord[len(newWord) - 2] and newWord[len(newWord) - 1] == c or len(newWord) > 1 and newWord[len(newWord) - 2] == newWord[len(newWord) - 1] and newWord[len(newWord) ...
ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP FUN...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
from itertools import groupby s = input().rstrip() s = [i for i in s] g = [] for key, value in groupby(s): g.append([len(list(value)), key]) for i in range(len(g) - 1): if g[i][0] >= 2 and g[i + 1][0] >= 2: g[i + 1][0] = 1 if g[i][0] >= 3: g[i][0] = 2 if g[-1][0] >= 3: g[-1][0] = 2 if g...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST FUNC_CALL VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER NUMBE...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() fs = [] f = 0 fs.append(s[0]) e = s[0] l = 0 for i in range(1, len(s)): if s[i] == e and f == 0: if i >= 2 and fs[l - 1] != fs[l - 2]: f = 1 fs.append(s[i]) l += 1 e = s[i] elif i < 2: fs.append(s[i]) l += 1 elif...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER ASSI...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = list(input()) sans = [] for i in s: if len(sans) == 0: sans.append((i, 1)) else: tmp, cnt = sans.pop() if tmp == i: sans.append((i, cnt + 1)) else: sans.append((tmp, cnt)) sans.append((i, 1)) sans = list(map(lambda x: [x[0], 1] if x[1] == 1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER ...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = "" for i in input(): if not ( len(s) >= 2 and s[-1] == s[-2] == i or len(s) >= 3 and s[-2] == s[-3] and s[-1] == i ): s += i print(s)
ASSIGN VAR STRING FOR VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = list(input()) ans = "" n = len(s) for i in range(n): if len(ans) >= 2 and ans[-1] == ans[-2] == s[i]: continue elif len(ans) >= 3 and (ans[-3] == ans[-2] and ans[-1] == s[i]): continue ans += s[i] print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() if len(s) == 1: print(s) exit() c = 1 st = "" for i in range(1, len(s)): if s[i] == s[i - 1]: c += 1 else: c = min(2, c) st += s[i - 1] * c c = 1 if c == 1: st += s[i] else: st += s[i - 1] * 2 c = 1 pre = 0 ans = "" for i in range(1, len(st)): if s...
ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER IF VAR ...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
from itertools import * 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())) it = lambda: tuple(map(int, input().split())) ls = lambda: list(input()) s = si() l = [] lch = [] for i, j in ...
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 VAR FUNC_CALL FUNC_CAL...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
import sys input = sys.stdin.readline s = list(input()) ans = "" for i in s: if len(ans) > 2 and ans[-3] == ans[-2] and ans[-1] == i: continue elif len(ans) > 1 and ans[-1] == ans[-2] == i: continue ans += i print(ans)
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() ans = s[0] doub = False ct = 1 for i in range(1, len(s)): if s[i] == s[i - 1]: ct += 1 if not doub: if ct <= 2: ans += s[i] doub = True rep = True elif not rep: doub = False else: ans += s[i] ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR IF VAR NUMBER VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR ASSIGN VAR NUMBER VAR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN V...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = list(input()) x = [] for c in s: i = len(x) if i >= 2 and x[i - 2] == x[i - 1] and x[i - 1] == c: continue if i >= 3 and x[i - 3] == x[i - 2] and x[i - 1] == c: continue x.append(c) print("".join(x))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR IF VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRI...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
import sys inf = float("inf") mod, MOD = 1000000007, 998244353 def get_array(): return list(map(int, sys.stdin.readline().strip().split())) def get_ints(): return map(int, sys.stdin.readline().strip().split()) def input(): return sys.stdin.readline().strip() string = input() ans = string[0] length ...
IMPORT ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() n = len(s) li = [s[i] for i in range(n)] g = [] for i in range(2, n): if li[i] == li[i - 1] and li[i] == li[i - 2]: g.append(i) li1 = [] k = 0 for i in range(n): if k < len(g) and i == g[k]: k += 1 else: li1.append(li[i]) n = len(li1) fl = 0 g = [] i = 1 while i < n: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR VAR V...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
def typo(text1): text = list(text1) k = len(text) i = 0 double_flag = 0 while i < k: j = 0 while i + j + 1 < k and text[i] == text[i + j + 1]: j += 1 if j >= 1: if not double_flag: double_flag = 1 else: doubl...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER IF VAR NUMBER IF VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER IF VAR N...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
from sys import stdin def f(s): s = list(s) if len(s) in (1, 2): return "".join(s) r = s[:2] i = 2 while i < len(s): if r[-2] == r[-1] == s[i]: i += 1 continue else: r.append(s[i]) i += 1 if len(r) < 4: return "".j...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER NUMBER RETURN FUNC_CALL STRING VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN FUNC_CALL STRING VAR ASSIGN VAR VA...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
from itertools import groupby s = input() x = [(k, len(list(g))) for k, g in groupby(s)] t = "" current = 0 for i in range(len(x)): key, cnt = x[i] if i > 0 and cnt > 1 and current > 1: current = 1 else: current = min(cnt, 2) t += key * current print(t)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR VAR EXPR FUNC_CALL...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
string = input() previous_char = "" previous_freq = 0 current_char = "" current_freq = 0 ans = list() i = 0 while i < len(string): current_char = string[i] i += 1 current_freq = 1 while i < len(string) and string[i] == current_char: current_freq += 1 i += 1 current_freq = min(current...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() l = [[s[0], 1]] for val in s[1:]: if val == l[-1][0]: l[-1][1] += 1 else: l.append([val, 1]) for val in l: if val[1] > 2: val[1] = 2 ll = len(l) for i in range(1, ll): if l[i][1] == l[i - 1][1] == 2: l[i][1] = 1 for val in l: print(val[0] * val[1], end="")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST LIST VAR NUMBER NUMBER FOR VAR VAR NUMBER IF VAR VAR NUMBER NUMBER VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR LIST VAR NUMBER FOR VAR VAR IF VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER VAR BIN_OP VAR...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s1 = input() s2 = " " for c in s1: if s2[-1] == c: if s2[-2] != c: s2 += c else: s2 += c s3 = "" i = 2 s2 += "_+_" while i < len(s2) - 3: if s2[i] == s2[i + 1] and s2[i + 2] == s2[i + 3]: s3 += s2[i : i + 3] i = i + 3 else: s3 += s2[i] i += 1 prin...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR VAR IF VAR NUMBER VAR IF VAR NUMBER VAR VAR VAR VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER VAR STRING WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() l = [0] * len(s) x = 0 x = 0 for i in range(1, len(s)): if s[i] == s[i - 1]: if l[i - 1] == 0: l[i] = 1 else: l[i] = -1 t = "" for i in range(len(s)): if l[i] != -1: t += s[i] l = [0] * len(t) for i in range(1, len(t)): if t[i] == t[i - 1]: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR V...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
given = input() l = len(given) typos = 0 yesno = [(1) for _ in range(l)] i = -1 while i < l - 1: i += 1 cur = given[i] while i < l - 2 and cur == given[i + 1] == given[i + 2]: i += 1 yesno[i] = 0 given = "".join([c for i, c in enumerate(given) if yesno[i] == 1]) l = len(given) typos = 0 yesn...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR WHILE VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL ST...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() c = 1 dic = {} if len(s) == 1: print(s) else: l = -1 for i in range(1, len(s)): if s[i] == s[i - 1]: c += 1 if s[i] != s[i - 1]: if c >= 2 and l >= 2: l = 1 else: l = c c = 1 if l >= 2 and c >...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR DICT IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() ans = "" for i in s: if len(ans) >= 2 and i == ans[-1] and i == ans[-2]: continue if len(ans) >= 3 and i == ans[-1] and ans[-2] == ans[-3]: continue ans += i print(ans)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
a = list(input()) x = "" t = 0 y = 1 while t != len(a): if t == 0: x += a[t] else: if a[t] == a[t - 1]: y += 1 else: x += a[t] y = 1 t += 1 continue if y > 2: t += 1 continue else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR VAR VAR ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR VAR VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR FUNC_CALL V...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
a = input() n = len(a) a += ";[-" a = list(a) stack = [] for i in range(n - 1, -1, -1): if a[i] == a[i + 1] and a[i + 2] == a[i + 3]: a[i + 1] = a[i + 2] stack.append(i + 1) if a[i] == a[i + 1] == a[i + 2]: stack.append(i + 1) for i in stack: a[i] = "" print("".join(a[:-3]))
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VA...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() l = list(s) l.append(1) l1 = [] c1, c = 1, 1 for i in range(len(s)): if l[i] == l[i + 1]: c1 += 1 else: l1.append([s[i], c1]) c1 = 1 n = len(l1) i = 0 while n > i: if i == n - 1: if l1[i][1] >= 2: print(l1[i][0] * 2, end="") else: p...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR ...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = [] l = input() c = 0 for i in l: if len(s) == 0 or len(s) == 1: s.append(i) elif i == s[c - 1] == s[c - 2]: continue elif i == s[c - 1] and s[c - 2] == s[c - 3]: continue else: s.append(i) c = c + 1 print("".join(s))
ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMB...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
ch = input() verif = False i = 0 n = len(ch) ch = ch + " " ch1 = "" while i < n: if ch[i] == ch[i + 1] and ch[i + 1] == ch[i + 2] and ch[i + 2] == ch[i + 3]: k = 0 elif ch[i] == ch[i + 1] and ch[i + 1] == ch[i + 2] and verif == True: ch1 += ch[i] i = i + 2 verif = False el...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR STRING WHILE VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMB...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() ans = "" last = "" lcount = 0 for i in range(len(s)): if last == "": ans += s[i] last = s[i] lcount = 1 elif last == s[i]: if lcount == 1: ans += s[i] lcount += 1 else: continue else: ans += s[i] last = s...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR STRING VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER IF VAR VAR VAR IF VAR NUMBER VAR VAR VAR VAR NUMBER VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER A...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
import sys s = input() n = len(s) if n < 3: print(s) sys.exit(0) s = list(s) for i in range(2, n): if s[i] == s[i - 1] and s[i - 1] == s[i - 2]: s[i - 2] = -1 ans = [] for i in s: if i != -1: ans.append(i) n = len(ans) if n < 4: print("".join(ans)) sys.exit(0) for i in range(3, ...
IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST FOR V...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() temp = s[0] c = 1 ans = "" ans += temp tempC = 0 for i in range(1, len(s)): if len(ans) < 2: ans += s[i] elif ans[len(ans) - 1] == ans[len(ans) - 2] and ans[len(ans) - 1] == s[i]: continue elif len(ans) >= 3 and ( ans[len(ans) - 2] == ans[len(ans) - 3] and ans[len(ans) - ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR IF FU...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() class Node: def __init__(self, value, i=0, previous=None, next=None): self.value = value self.i = i self.previous = previous self.next = next class LL: def __init__(self): self.size = 0 self.start = None def from_str(self, s): self.s...
ASSIGN VAR FUNC_CALL VAR CLASS_DEF FUNC_DEF NUMBER NONE NONE ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NONE FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FOR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VA...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
from itertools import groupby s = input() lst = list("".join(g) for _, g in groupby(s)) if len(lst) == 1: if len(lst[0]) > 2: lst[0] = lst[0][0] * 2 print(lst[0]) exit(0) for i in range(len(lst) - 1): if len(lst[i]) > 1: if len(lst[i]) > 2: lst[i] = lst[i][0] * 2 if ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
def fixing(s, i, n, b): t, k = s[i], i + 1 if not b and k < n and s[k] == s[i]: t = t * 2 k += 1 while k < n and s[k] == s[i]: k += 1 return k, t, len(t) > 1 def main(): s = list(input()) i, n, b = 0, len(s), False w = "" while i < n: i, t, b = fixing(s,...
FUNC_DEF ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR VAR NUMBER RETURN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING W...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() n = len(s) arr = [] for i in range(n): arr.append(s[i]) for i in range(n - 2): if arr[i] == arr[i + 1] == arr[i + 2]: arr[i] = "" arr1 = [] for i in arr: if i != "": arr1.append(i) arr = arr1 n = len(arr) for i in range(n - 3): if arr[i] == arr[i + 1] and arr[i + 2] == arr[i ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR LIST FOR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = list(input()) if s.count("a") == len(s): s = "a" * 2 else: for i in range(len(s)): if len(s) < i + 3: break if s[i] == s[i + 1] and s[i + 2] == s[i + 1]: del s[i] ans = "" for ch in range(len(s)): if len(ans) >= 2: if ( s[ch] == ans[-1] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF FUNC_CALL VAR STRING FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUN...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() res = "" for ch in s: ok = True if len(res) >= 2: if ch == res[-1] and res[-1] == res[-2]: ok = False if len(res) >= 3: if ch == res[-1] and res[-2] == res[-3]: ok = False if ok: res += ch print(res)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR VAR
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
x = input() n = len(x) s = "" if n < 3: print(x) else: for i in range(2): s += x[i] for i in range(2, n): if x[i] == s[-1] == s[-2]: pass else: s += x[i] n = len(s) inc = [1] dp = [False] if n > 1: if s[1] == s[0]: dp.append...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR NUMBER VAR NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER IF VAR NUMBER IF ...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
def correct(A): a = A[0] B = [A[0]] C = [1] c = 0 for i in range(1, len(A)): if A[i] == a: C[c] = C[c] + 1 else: B.append(A[i]) C.append(1) a = A[i] c = c + 1 correctto(B, C) def correctto(B, C): if C[0] > 2: ...
FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR LIST VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VA...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = [".", "@", "%"] for i in input(): if s[-1] == i and (s[-2] == i or s[-2] == s[-3]): s.pop() s.append(i) print("".join(s[3:]))
ASSIGN VAR LIST STRING STRING STRING FOR VAR FUNC_CALL VAR IF VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR NUMBER
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
def main(): x = input() x += "0" curPlat = 0 lastPlat = 0 lastVal = 0 for c in x: if c == lastVal: curPlat += 1 else: if curPlat >= 3: curPlat = 2 if lastPlat >= 2: curPlat = 1 for i in range(curPlat)...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR STRING ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
from sys import stdin, stdout def main(s): segs = [] cur = [0, 0, s[0]] for i, c in enumerate(s[1:]): if cur[2] != c: segs.append(cur) cur = [i, i, c] prev = c else: cur[1] += 1 segs.append(cur) for seg in segs: if seg[1] - se...
FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST NUMBER NUMBER VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR VAR VAR ASSIGN VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR IF BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER BIN_OP VA...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
count = 0 startIndex = 0 hasDuplicates = False printWord = "" doubleTest = "" word = input() for i in range(len(word)): if word[i] == doubleTest: if count < 2 and hasDuplicates == False: printWord += word[i] doubleTest = word[i] count += 1 else: if count > 1: ...
ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR IF VAR NUMBER VAR NUMBER VAR VAR VAR ASSIGN VAR VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER V...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = list(input()) l = [] if len(s) <= 2: print("".join(s)) elif len(s) == 3: if s[0] == s[1] == s[2]: s = s[:2] print("".join(s)) else: c = 0 l.append(s[0]) l.append(s[1]) c += 2 if l[0] == l[1] == s[2]: pass else: l.append(s[2]) c += 1 for i in ra...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING VAR IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
string = list(input()) z = len(string) cnt = 0 flag = False while cnt < z - 2: if string[cnt] == string[cnt + 1] == string[cnt + 2]: string[cnt] = "" cnt += 1 cnt = 0 string = [x for x in string if x != ""] try: while cnt < z - 2: if string[cnt] == string[cnt + 1] and string[cnt + 2] == stri...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR VAR STRING VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR VAR STRING WHILE VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_O...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
str = input() arr, cur = len(str) * [0], 0 for i in range(len(str)): if str[i - cur] == str[i]: cur += 1 else: cur = 1 arr[i - cur + 1] = cur flag, it, i = 0, 0, 0 while i < len(str): it = arr[i] if arr[i] > 1 and not flag: flag = 1 else: if arr[i] > 1: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() count = 1 prevCount = 1 stack = [s[0]] for i in range(1, len(s)): if s[i] == s[i - 1]: count += 1 else: prevCount = count count = 1 if count == 2 and prevCount >= 2: count = 1 continue elif count >= 3: continue else: stack.append(s[...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
def main(): c = input() c = list(c) v = c[0] k = 1 for i in range(1, len(c)): if v == c[i]: k += 1 if k > 2: c[i] = " " else: v = c[i] k = 1 c = [i for i in c if i != " "] for i in range(len(c) - 1): if c...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR VAR STRING FOR VAR FUNC_CALL VAR BIN_OP FUNC_CAL...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
l = list(input()) n = len(l) i = 0 while i < n: if i + 2 < n and l[i] == l[i + 2] and l[i] == l[i + 1] and l[i] != ".": l[i] = "." i += 1 l = [i for i in l if i != "."] i = 0 n = len(l) while i < n: if ( i + 3 < n and l[i] == l[i + 1] and l[i + 2] == l[i + 3] and l[i]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR VAR STRING ASSIGN VAR VAR STRING VAR NUMBER ASSIGN VAR VAR VAR VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE ...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() x = 0 l1 = [] c = 0 for i in range(0, len(s)): if i == 0: l1.append(s[i]) c = 1 f = s[0] elif c < 2: l1.append(s[i]) if s[i] == f: c += 1 else: f = s[i] c = 1 elif s[i] == f: c += 1 else: l1.a...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER IF VAR VAR ...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = str(input()) i = 0 n = len(s) p = "" while i < n: x = True k = len(p) if k > 1 and p[-1] == p[-2] and p[-1] == s[i]: x = False elif k > 2 and p[-3] == p[-2] and p[-1] == s[i]: x = False if x: p += s[i] i += 1 print(p)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING WHILE VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR ASSIGN VAR NUMBER IF VAR VA...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() ans = [] for i in range(len(s)): if i > 1: if s[i] == ans[-1] and ans[-2] == ans[-1]: continue if i > 2: if s[i] == ans[-1] and ans[-2] == ans[-3]: continue ans.append(s[i]) print(*ans, sep="")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR STRING
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
strs = input() arr = [] prev = "" count = 0 strsarr = [] for i in strs: if i != prev: arr.append(count) strsarr.append(prev) prev = i count = 1 else: count += 1 arr.pop(0) arr.append(count) strsarr.append(i) strsarr.pop(0) ans = "" n = len(arr) flag = 0 ans = [] for i, j ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR STRIN...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() res = [] n = len(s) i = 0 prevTwo = False while i < n: cnt = 0 curr = s[i] while i < n and s[i] == curr: i += 1 cnt += 1 if prevTwo: prevTwo = False res.append(curr) else: prevTwo = True if cnt > 1 else False res.append(curr * min(cnt, 2)) ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR WHILE VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR F...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
def go(): o = "" for c in input(): if len(o) > 2 and o[-1] == c and o[-2] == o[-3]: continue if len(o) > 1 and o[-2] == o[-1] == c: continue o += c return o print(go())
FUNC_DEF ASSIGN VAR STRING FOR VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR NUMBER IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR VAR RETURN VAR EXPR FUNC_CALL VAR FUNC_CALL VAR
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
class GoodString: def __init__(self): self.string = [] self.prev = [] self.current = [] def appendChar(self, char): if len(self.current) == 0: self.current.append(char) elif self.current[-1] != char: for ii in range(len(self.prev)): ...
CLASS_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FUNC_DEF IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST VAR IF FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VA...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() a = [] k = 0 for i in range(0, len(s)): if i == len(s) - 1: if k >= 1: a.append(s[i]) a.append(s[i]) k = 0 continue a.append(s[i]) continue if s[i] == s[i + 1]: k = k + 1 continue if k >= 1: a.append(...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() n = len(s) if n == 1: t = s else: t = s[0] + s[1] i = 2 j = 1 while i < n: if s[i] == t[j] and s[i] == t[j - 1]: i += 1 continue elif s[i] == t[j] and j > 1 and t[j - 1] == t[j - 2]: i += 1 continue else: t += s[i] i += 1 j += 1 pri...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER VA...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
import sys sys.setrecursionlimit(10**8) try: FILE_POINTER = open("input.inpt") input = FILE_POINTER.readline except: FILE_POINTER = None input = sys.stdin.readline s = input().strip() ans = s[0] cnt = 1 n = len(s) for i in range(1, n): if s[i] == s[i - 1]: if cnt == 1: ans += s[...
IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR ASSIGN VAR NONE ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR VAR VAR...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
def readln(): return tuple(map(int, input().split())) cnt = [] for s in list(input() + "#"): if cnt == [] or cnt[-1][0] != s: cnt.append([s, 1]) else: cnt[-1][1] += 1 ans = [] tmp = [] for s, c in cnt: if c == 1: for _ in range(len(tmp)): if _ % 2 == 0: ...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR STRING IF VAR LIST VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR LIST VAR NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR FUNC...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
def main(): s, l, z = input(), [], False a, b, f = "", s[0], l.append u = v = 0 for s in (s, "+-"): for c in s: if b == c: v += 1 else: if z: z = False elif u > 1: z = True ...
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR LIST NUMBER ASSIGN VAR VAR VAR STRING VAR NUMBER VAR ASSIGN VAR VAR NUMBER FOR VAR VAR STRING FOR VAR VAR IF VAR VAR VAR NUMBER IF VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR NUMBER VAR VAR EXPR ...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
__author__ = "Alex" s = input().strip() cur = "#" cnt = 0 pd = False ans = [] for x in s: if x != cur: cnt = 0 cur = x cnt += 1 if cnt == 3: cnt -= 1 else: ans.append(x) cur = "#" cnt = 0 s = ans ans = [] for x in s: if x != cur: if cnt != 2: pd = ...
ASSIGN VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR VAR IF ...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
a = list(input()) b = [] c = 1 for i in range(1, len(a)): if a[i] == a[i - 1]: c += 1 else: b.append(c) c = 1 b.append(c) for i in range(len(b)): if b[i] > 2: b[i] = 2 for i in range(1, len(b)): if b[i] == 2 and b[i] == b[i - 1]: b[i] = 1 s = "" s += a[0] for i in...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() def check(a1, a2, ans): s = "" c1 = c2 = c3 = None c1 = ans[-1] c2 = ans[-2] if len(ans) >= 3: c3 = ans[-3] else: c3 = None if c1 == c2: if c1 == a1 and c1 == a2: return [] elif c1 == a1 and c1 != a2: return [a2] e...
ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR STRING ASSIGN VAR VAR VAR NONE ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NONE IF VAR VAR IF VAR VAR VAR VAR RETURN LIST IF VAR VAR VAR VAR RETURN LIST VAR IF VAR VAR RETURN LIST VAR RETURN LIST VAR VAR IF VAR VAR...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() i = 0 n = len(s) ans = "" while i < n: curr = 0 start = i while i < n and s[start] == s[i]: i += 1 curr += 1 if curr > 2: ans += 2 * s[start] else: ans += curr * s[start] n = len(ans) res = "" i = 0 while i < n: if i + 3 >= n: res += ans[i:] ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING WHILE VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR NUMBER VAR BIN_OP NUMBER VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER WHI...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
word = input() solution = [word[0]] state = 0 for pos in range(1, len(word)): if state == 0: solution.append(word[pos]) if word[pos] == word[pos - 1]: state = 1 elif state == 1: if word[pos] != word[pos - 1]: state = 2 solution.append(word[pos]) el...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR VAR VAR BIN_...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() ans = s[:2] for i in range(2, len(s)): if s[i] == ans[len(ans) - 1] and s[i] == ans[len(ans) - 2]: continue elif ( len(ans) > 2 and s[i] == ans[len(ans) - 1] and ans[len(ans) - 2] == ans[len(ans) - 3] ): continue else: ans += s[i] print(ans)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VA...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
def fun(s): cnt = 1 ans = [] cas = [] num = [] for i in range(len(s)): if i == 0: flag = s[i] continue if s[i] != s[i - 1]: cas.append(s[i - 1]) if cnt > 1: ans.append(s[i - 1] + s[i - 1]) num.append(2) ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() s1 = "" count = 0 prev = 0 for i in range(len(s) - 1): if s[i] == s[i + 1]: count += 1 if count == 1: s1 += s[i] elif count >= 1 and prev == 0: s1 += s[i] prev = 1 count = 0 elif count == 0: s1 += s[i] prev = 0 count = 0...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR VAR IF VAR NUMBER VAR NUMBER VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR VAR VAR ASSIGN VAR NUMBER ...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() t = "" for i in range(len(s)): if len(t) >= 2 and s[i] == t[-1]: if t[-2] != t[-1]: t += s[i] else: t += s[i] ans = "" i = 0 t += " " while i < len(t) - 3: if t[i] == t[i + 1] and t[i + 2] == t[i + 3]: ans += t[i] ans += t[i + 1] ans += t[i +...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR VAR VAR VAR VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER VAR STRING WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMB...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
string = list(input()) ans = [] prev_cnt, cnt = 1, 1 for i, ch in enumerate(string): if i > 0: if string[i - 1] == ch: cnt += 1 else: if cnt == 1: ans.append(string[i - 1]) elif cnt == 2 or cnt >= 3: ans.append(string[i - 1]) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP V...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
n = input() l = len(n) if l < 3: print(n) else: s = "-" + n[:2] i = 2 while i < l: a = s[-3] b = s[-2] c = s[-1] if c == n[i]: if b == c or a == b: i += 1 else: s += n[i] i += 1 else: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER EXPR...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = [*input()] c = [0] * len(s) i = 0 z = 0 while i < len(s): j = i t = j while t < len(s) and s[j] == s[t]: c[i] += 1 t += 1 y = c[i] while c[i] > 2 or z == 2 and z == c[i]: s[j] = " " c[i] -= 1 j += 1 z = c[i] i += y for i in s: if i != " ": ...
ASSIGN VAR LIST FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR WHILE VAR VAR NUMBER VAR NUMBER VAR VAR VAR ASSIGN VAR VAR ...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = list(input()) n = len(s) flag = 0 for i in range(1, n): if s[i] == s[i - 1] and flag == 0: flag = 1 elif s[i] == s[i - 1] and (flag == 1 or flag == 3): s[i - 1] = "" elif s[i] != s[i - 1] and (flag == 1 or flag == 3): if flag == 3: flag = 0 else: f...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER STRING IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR ...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
t, p = input(), [] n, k, x = 0, True, t[0] for i in t[1:] + " ": if i == x: n += 1 else: if n and k: p += [x, x] k = False else: p.append(x) k = True x, n = i, 0 print("".join(p))
ASSIGN VAR VAR FUNC_CALL VAR LIST ASSIGN VAR VAR VAR NUMBER NUMBER VAR NUMBER FOR VAR BIN_OP VAR NUMBER STRING IF VAR VAR VAR NUMBER IF VAR VAR VAR LIST VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING VAR
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() a = [] if len(s) < 3: print(s) else: for i in s: if i not in a: a.append(i) elif len(a) >= 3: if a[-1] == i and a[-2] == i: continue elif a[-1] == i and a[-2] == a[-3]: continue else: a.ap...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR VAR NUMBER VAR IF VAR NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR VAR NUMBER V...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = list(input()) if len(set(s)) == 1: print(s[0] * min(len(s), 2)) exit() n = len(s) lis = [] c = 1 for i in range(1, n): if s[i] == s[i - 1]: c += 1 else: lis.append([s[i - 1], c]) c = 1 lis.append([s[-1], c]) a = len(lis) ans = "" ans += min(lis[0][1], 2) * lis[0][0] + min(lis...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
import sys input = sys.stdin.readline def solve(): r = [] for c in input().strip(): r.append(c) while True: if len(r) > 2 and r[-1] == r[-2] and r[-1] == r[-3]: r.pop() elif len(r) > 3 and r[-1] == r[-2] and r[-3] == r[-4]: r.pop() ...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR WHILE NUMBER IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input() r = [] s += "8" c = 0 k = [] for i in range(len(s) - 1): c += 1 if s[i] != s[i + 1]: k.append(s[i]) if c > 2: c = 2 r.append(c) c = 0 for i in range(1, len(r)): if r[i] == 2 and r[i - 1] == 2: r[i] = 1 for i in range(len(k)): print(k[i] * r...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST VAR STRING ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CA...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = input().strip() stack = [] for i in range(len(s)): if len(stack) == 0: stack.append([s[i], 1]) elif len(stack) == 1: if stack[-1][0] == s[i]: stack.append([s[i], 2]) else: stack.append([s[i], 1]) elif s[i] == stack[-1][0] and stack[-1][1] == 1 and stack[-2...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER NUMBER VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR NUMBER IF VAR VAR VAR NUMBER NUMBE...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = list(input()) c = 1 last = s[0] dele = [] for i in range(1, len(s)): if s[i] == last: c += 1 if c >= 3: dele.append(i) else: last = s[i] c = 1 for ind in dele[::-1]: del s[ind] dele = [] cc = 0 c = 0 last = "" bre = 0 for i in range(len(s)): if s[i] == las...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR NUMBER VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
from sys import stdin, stdout def solve(): s = stdin.readline().strip() res = s[0] rep = 1 previous_rep = 0 for i in range(1, len(s)): if s[i] == s[i - 1]: if rep >= (1 if previous_rep else 2): continue else: rep += 1 else: ...
FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VA...
Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos. In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ...
s = [i for i in input()] moved = True while moved: moved = False for i in range(len(s) - 3, -1, -1): if s[i] == s[i + 1] and s[i] == s[i + 2] and s[i + 1] == s[i + 2]: s.pop(i + 1) moved = True i = len(s) - 4 while i >= 0: if s[i] == s[i + 1] and s[i + 2] == s[i +...
ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR ...