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" contains a typo). Besides, a couple of identical letters immediately followed by another couple of identical letters is a typo too (for example, words "helloo" and "wwaatt" contain typos).

Write a code that deletes the minimum number of letters from a word, correcting described typos in the word. You are allowed to delete letters from both ends and from the middle of the word.


-----Input-----

The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.


-----Output-----

Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters.

If there are multiple solutions, print any of them.


-----Examples-----
Input
helloo

Output
hello

Input
woooooow

Output
woow



-----Note-----

The second valid answer to the test from the statement is "heloo".

Difficulty: interview

Starter code:

Solutions:
s = input().strip()
if len(s)<=2:
    print(s)
    return
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)

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
yesno = [1 for _ in range(l)]
i = 0
while i < l-3:
    if given[i] == given[i+1] and given[i+2] == given[i+3]:
        yesno[i+2] = 0
        i += 3
    else:
        i += 1
print("".join([c for i,c in enumerate(given) if yesno[i]==1]))

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:
            x += a[t]
    t += 1
ans = ''
x = list(x)
i = 0

d = []
while i != len(x):
    if i == 0:
        d.append(x[i])
        i += 1
    else:
        if x[i] == x[i - 1]:
            d[-1]+= x[i]
            i += 1
        else:
            d.append(x[i])
            i += 1
#d.append('^')
i = 0
while i != len(d):
    if i == 0:
        ans+= d[i]
        i+= 1
    else:
        if len(d[i-1]) == 2:
            if len(d[i]) == 2:
                ans += d[i][0]
                d[i] = d[i][0]
            else:
                ans += d[i]
        else:
            ans += d[i]
        i += 1
print(ans)                


s=input()
C=[0]*len(s)
ind=-1
x=True
for i in range(len(s)):
    if(x):
        C[i]=1
        y=True
        x=False
        ind+=1
        continue
    if(y):
        if(s[i]==s[ind]):
            C[i]=1
            z=True
            y=False
            ind+=1
            continue
        else:
            C[i]=1
            ind+=1
            continue
    if(z):
        if(s[i]==s[ind]):
            C[i]=0
            z=True
            continue
        else:
            C[i]=1
            z=False
            a=True
            ind2=i
            continue
    if(a):
        if(s[i]==s[ind2]):
            C[i]=0
            continue
        else:
            ind=i
            C[i]=1
            a=False
            y=True
for i in range(len(s)):
    if(C[i]):
        print(s[i],end="")


s = input()
s1 = list(s[:2])
for i in range(2,len(s)):
    if not(s[i] == s[i-1] == s[i-2]):
        s1.append(s[i])
ans = s1[:3]
if len(ans) >= 3:
    for i in range(3, len(s1)):
        if not(s1[i] == s1[i-1] and s1[i-2] == s1[i-3]):
            ans += s1[i]
        else:
            s1[i] = '!'
for i in range(len(ans)):
    print(ans[i], end = '')

t = list(input().strip())
d = []
for i in range(len(t)-1):
    if t[i]==t[i+1]:
        d.append(i)
for i in range(len(d)-1):
    if d[i+1]-d[i]==1:
        t[d[i]] = ''
a=''.join(t)
if len(a) < 3:
    print(a)
else:
    ans = a[:3]
    for i in range(3,len(a)):
        if not (a[i]==ans[-1] and ans[-2]==ans[-3]):
            ans += a[i]
    print(ans)

3

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:
                ans.append(tmp[_]*2)
            else:
                ans.append(tmp[_])
        ans.append(s)
        tmp = []
    else:
        tmp.append(s)
print(''.join(ans[:-1]))


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))

__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
	lastthree = formated[0], formated[1], formated[2]

	answer = formated[0:3]

	for i in range(3,len(formated)):
		c = formated[i]
		if not (lastthree[0]==lastthree[1] and lastthree[2]==c):
			answer += c
			lastthree = lastthree[1], lastthree[2], c

	return answer

def main():
	s = input()

	print(actions(s))

def __starting_point(): main()
__starting_point()

#NOOOOOOO!

s=list( input() )
l=len(s)
ln = []

if(l<2):
	ln=s
else:
	ln= s[0:2]
	
j=2	
for i in range(2,l):
	if s[i]!=ln[j-1] or s[i]!=ln[j-2]: #not the third consecutive
		if ln[j-1]!=ln[j-2] or i==l-1 or s[i]!=s[i+1]: #not two couples
			ln.append(s[i])
			j+=1
			
print(''.join(ln))




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
print(t)



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, i, n, b)
		w += t
	print(''.join(w))

def __starting_point():
	main()
__starting_point()

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))


a = ""
for c in input():
  if len(a) > 2 and a[-3] == a[-2] and a[-1] == c or len(a) > 1 and a[-2] == a[-1] == c:
    continue
  a += c
print(a)

__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 = False
        cnt = 0
        cur = x
    cnt += 1
    if not (cnt == 2 and pd):
        ans.append(x)
    else:
        pd = False
        cnt -= 1
    if cnt == 2 and not pd:
        pd = True
print(''.join(ans))

s=input()
new=''
g=''
_c=0
_two=False
for u in s:
    if u!=g:
        if _c>=2: _two=True
        if _c==1: _two=False
        _c=1
        new=new+u
        g=u

    else:
        if _c<2 and _two==False:
            new=new+u
            g=u

            _c+=1
print(new)

import sys
import math            

s = input()
l = len(s)

p = '1'
k = 0
v = 1
for i in range(l):
    if(p != s[i]):
        p = s[i]
        if(v == 1):
            k = 0
        v = 1
        sys.stdout.write(p)
    else:
        v += 1
        if(v == 2):
            if(k % 2 == 0):
                sys.stdout.write(p)
                k = 1
            else:
                 k = 0

import sys
import math            

s = input()
l = len(s)

p = '1'
k = 0
v = 1
res = []
for i in range(l):
    if(p != s[i]):
        p = s[i]
        if(v == 1):
            k = 0
        v = 1
        res.append(p)
    else:
        v += 1
        if(v == 2):
            if(k % 2 == 0):
                res.append(p)
                k = 1
            else:
                 k = 0

print("".join(res))

import sys
import math            

s = input()

p = '1'
k = 0
v = 1
res = []
for i in s:
    if(p != i):
        p = i
        if(v == 1):
            k = 0
        v = 1
        res.append(p)
    else:
        v += 1
        if(v == 2):
            if(k % 2 == 0):
                res.append(p)
                k = 1
            else:
                 k = 0

print("".join(res))

import sys
import math            

s = input()

p = '1'
k = 0
v = 1
res = ''
for i in s:
    if(p != i):
        p = i
        if(v == 1):
            k = 0
        v = 1
        res += p
    else:
        v += 1
        if(v == 2):
            if(k % 2 == 0):
                res += p
                k = 1
            else:
                k = 0

print(res)

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)



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
print(s3)


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)