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: MEDIUM
Tags: Implementation

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
s = input().rstrip()
n = len(s)
stack = []
for ch in s:
	if len(stack) <= 1 or not stack[-1] == stack[-2] == ch:
		stack.append(ch)
s = ''.join(stack)
stack = []
for ch in s:
	if len(stack) <= 2 or not (stack[-3] == stack[-2] and stack[-1] == ch):
		stack.append(ch)
print(''.join(stack))


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


import sys
from math import log2, floor, ceil, sqrt, gcd
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 1000000007
st = ri()
new = []
cnt = 0
ch = -1
for i in st:
	if i == ch:
		cnt += 1
		if cnt <= 2:
			new.append(i)
	else:
		ch = i
		new.append(i)
		cnt = 1
new2 = []
a = new
cnt = 0
ch = -1
prev = -1
for i in range(len(a)):
	if len(new2) >= 3:
		if a[i] == new2[-1]:
			if new2[-2] != new2[-3]:
				new2.append(a[i])
		else:
			new2.append(a[i])
	else:
		new2.append(a[i])
print(''.join(new2))


s = input()
count = 0
n = len(s)
res = []
last = s[0]
for i in range(n):
	if s[i] == last and count == 0:
		count = 1
		res.append(s[i])
	elif s[i] == last and count == 1:
		count = 2
		res.append(s[i])
	elif s[i] != last and count == 1:
		res.append(s[i])
	elif s[i] != last and count == 2:
		count = 3
		res.append(s[i])
	elif s[i] != last and count == 3:
		count = 1
		res.append(s[i])
	last = s[i]
print(''.join(res))


from sys import stdin
input = stdin.readline

def typo(s):
	ans = ''
	for i in s:
		try:
			if ans[-1] == ans[-2] == i:
				continue
			if ans[-1] == i and ans[-2] == ans[-3] and (ans[-2] != i):
				continue
		except:
			pass
		ans += i
	return ans
print(typo(input().strip()))


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


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])
	elif word[pos] != word[pos - 1]:
		state = 0
		solution.append(word[pos])
print(''.join(solution))


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, n):
	if ans[i] == ans[i - 1] and ans[i - 2] == ans[i - 3]:
		ans[i] = -1
s = ''
for i in ans:
	if i != -1:
		s += i
print(s)


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] and ans[-2] == s[ch] or (s[ch] == ans[-1] and ans[len(ans) - 2] == ans[len(ans) - 3]):
			pass
		else:
			ans = ans + s[ch]
	else:
		ans = ans + s[ch]
print(ans)


import sys
arr = []

def canAdd(arr, a):
	if len(arr) >= 2 and arr[-1] == arr[-2] == a or (len(arr) >= 3 and arr[-1] == a and (arr[-2] == arr[-3])):
		return False
	return True
for x in sys.stdin.read().strip():
	if canAdd(arr, x):
		arr.append(x)
print(''.join(arr))


import time, math, bisect
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
pi = 3.141592653589793

def Ii():
	return int(stdin.readline())

def Is():
	return stdin.readline()

def In():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def Pi(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def readTree():
	v = int(input())
	adj = [set() for i in range(v + 1)]
	for i in range(v - 1):
		(u1, u2) = In()
		adj[u1].add(u2)
		adj[u2].add(u1)
	return (adj, v)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def solve():
	s = input()
	n = len(s)
	new = s[0]
	d = {}
	(pcons, cons, val) = (False, False, 1)
	for i in range(1, n):
		if s[i] == s[i - 1]:
			if pcons == False:
				cons = True
				val += 1
				if val != 3:
					new += s[i]
				else:
					val = 2
			else:
				cons = False
		else:
			val = 1
			new += s[i]
			cons = False
		if i < n - 1 and s[i] != s[i + 1]:
			if cons == True:
				pcons = True
			else:
				pcons = False
	print(new)
solve()


import re
s = input()
pattern = 'a+'
for i in range(98, 97 + 26):
	pattern += '|' + chr(i) + '+'
repeatCharacters = re.findall(pattern, s)
for i in range(len(repeatCharacters)):
	string = repeatCharacters[i]
	if len(string) >= 3:
		repeatCharacters[i] = string[:2]
for i in range(1, len(repeatCharacters)):
	string = repeatCharacters[i]
	if len(string) == 2 and len(repeatCharacters[i - 1]) == 2:
		repeatCharacters[i] = string[:1]
print(''.join(repeatCharacters))


s = []
l = input()
c = 0
for i in l:
	if len(s) == 0 or len(s) == 1 or (not (i == s[c - 1] == s[c - 2] or (i == s[c - 1] and s[c - 2] == s[c - 3]))):
		s.append(i)
		c = c + 1
print(''.join(s))


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) - 1] == c)):
		continue
	newWord += c
print(newWord)


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


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[i]
		lcount = 1
last = ''
lcount = 0
result = ''
i = 0
flag = False
while i < len(ans) - 1:
	if ans[i] != ans[i + 1]:
		result += ans[i]
		i += 1
		flag = False
	else:
		if flag == False:
			result += ans[i] + ans[i]
			last = ans[i]
			flag = True
		else:
			result += ans[i]
			last = ans[i]
			flag = False
		i += 2
if i == len(ans) - 1:
	result += ans[-1]
print(result)


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)


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[i] == c[i + 1]:
			if i + 3 < len(c) and c[i + 2] == c[i + 3]:
				c[i + 3] = ' '
	c = [i for i in c if i != ' ']
	return c
print(''.join(main()))


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.append(s[i])
		f = s[i]
		c = 1
c = 0
flag = 0
l2 = []
for i in range(0, len(l1)):
	if flag == 0:
		l2.append(l1[i])
		if c == 0:
			c = 1
			f = l1[i]
		elif l1[i] == f:
			c = 2
			flag = 1
		else:
			c = 1
			f = l1[i]
	elif c == 2:
		x = l1[i]
		c -= 1
		l2.append(l1[i])
	elif l1[i] == x:
		c = 0
		flag = 0
	else:
		l2.append(l1[i])
		f = l1[i]
		c = 1
		flag = 0
print(''.join(l2))


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)


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 + 2]
		i += 3
	else:
		ans += t[i]
	i += 1
print(ans)


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)


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


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]
		elif a1 == a2:
			return [a1]
		else:
			return [a1, a2]
	elif c2 == c3:
		if c1 == a1 and c1 == a2:
			return []
		elif c1 == a1 and c1 != a2:
			return [a2]
		else:
			return [a1, a2]
	elif c1 == a1 == a2:
		return [a1]
	else:
		return [a1, a2]
if len(s) <= 2:
	print(s)
elif len(s) == 3:
	if s[0] == s[1] == s[2]:
		print(s[:2])
	else:
		print(s)
else:
	i = 2
	ans = []
	ans.append(s[0])
	ans.append(s[1])
	while i <= len(s) - 1:
		c1 = s[i]
		if i + 1 <= len(s) - 1:
			c2 = s[i + 1]
		else:
			c2 = ''
		ans += check(c1, c2, ans)
		i += 2
	print(''.join(ans))


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))
print(''.join(res))


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:
			previous_rep = True if rep > 1 else False
			rep = 1
		res += s[i]
	print(res)
LOCAL_TEST = not __debug__
if LOCAL_TEST:
	infile = __file__.split('.')[0] + '-test.in'
	stdin = open(infile, 'r')
tcs = int(stdin.readline()) if LOCAL_TEST else 1
t = 1
while t <= tcs:
	solve()
	t += 1


def fun1(st):
	le = len(st)
	stack = [0] * le
	i = 0
	x = 0
	sh = 0
	h = 0
	ans = list(st)
	while i < len(ans):
		if ans[i] == '#':
			stack[i] = stack[i - 1]
			i += 1
			continue
		if i > 0 and ans[i] == ans[i - 1]:
			stack[i] = stack[i - 1] + 1
		else:
			stack[i] = 0
		if i < len(ans) - 1 and ans[i] != ans[i + 1] or i == len(ans) - 1:
			p = 0
			if i < le and stack[i] == 0:
				ans[i] = ans[i]
			elif i > 2 and stack[i] == 1 and (stack[i - 2] == 1):
				ans[i] = '#'
				h = 1
				sh = 0
				i -= 2
			elif stack[i] != 1:
				h = i
				x = i
				while stack[x - 1] != 0:
					ans[x] = '#'
					x -= 1
				i = x - 3
		i += 1
	return ''.join((c for c in ans if c != '#'))
st = input()
print(fun1(st))


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]:
			if cnt == 0:
				cnt = 1
				snd.append(sn[i])
				snd.append(sn[i + 1])
				i += 2
			else:
				cnt = 0
				snd.append(sn[i])
				i += 2
		else:
			snd.append(sn[i])
			cnt = 0
			i += 1
	else:
		snd.append(sn[i])
		i += 1
for i in snd:
	print(i, end='')
print('')


import functools
a = input()
a_list = [a[i] for i in range(len(a))]
for i in range(len(a) - 2):
	if a_list[i] == a_list[i + 1] == a_list[i + 2]:
		a_list[i] = 0
a_list = list(filter(lambda x: x != 0, a_list))
for i in range(len(a_list) - 3):
	if a_list[i] == a_list[i + 1] and a_list[i + 2] == a_list[i + 3]:
		a_list[i + 3] = 0
a_list = list(filter(lambda x: x != 0, a_list))
print(''.join(a_list))


s = list(input())
n = len(s)
count = 0
i = 0
answer = [1] * n
while i < n - 2:
	if s[i] != s[i + 1] or answer[i] != 1:
		i += 1
	else:
		j = i + 2
		while j < n and s[j] == s[i]:
			answer[j] = -1
			j += 1
		while j < n - 1 and s[j] == s[j + 1]:
			answer[j + 1] = -1
			j += 1
		i = j
ans = ''
for i in range(n):
	if answer[i] != -1:
		ans += s[i]
print(ans)


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)


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:
				double_flag = 3 - double_flag
		else:
			double_flag = 0
		if double_flag == 1:
			del text[i + 2:i + j + 1]
			k -= j - 1
			i += 2
		elif double_flag == 2:
			del text[i + 1:i + j + 1]
			k -= j
			i += 1
		else:
			i += 1
	return ''.join(text)
print(typo(input()))


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 + 3]:
		arr[i + 2] = ''
for i in arr:
	print(i, end='')
print()


import sys
s = sys.stdin.readline()[:-1]
ans = ''
if len(s) < 3:
	ans = s
else:
	last = s[0]
	lastCount = 1
	count = 1
	i = 1
	ans = last
	fixed = False
	while i < len(s):
		if s[i] == last:
			count = count + 1
			if count == 2 and (lastCount < 2 or fixed):
				ans = ans + s[i]
				fixed = False
			elif count == 2:
				fixed = True
		else:
			lastCount = count
			count = 1
			last = s[i]
			ans = ans + s[i]
		i = i + 1
print(ans)


import os
import sys
from io import BytesIO, IOBase
import math as M
import itertools as ITR
from collections import defaultdict as D
from collections import Counter as C
from collections import deque as Q
import threading
from functools import lru_cache, reduce
from functools import cmp_to_key as CMP
from bisect import bisect_left as BL
from bisect import bisect_right as BR
import random as R
import string
import cmath, time
enum = enumerate
start_time = time.time()
MOD = 1000000007
MA = float('inf')
MI = float('-inf')

def increase_stack():
	sys.setrecursionlimit(2 ** 32 // 2 - 1)
	threading.stack_size(1 << 27)
	t = threading.Thread(target=main)
	t.start()
	t.join()

def prints(a):
	print(a, end=' ')

def binary(n):
	return bin(n)[2:]

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def maxfactor(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
	if q:
		return q[-1]

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(M.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	l.sort()
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def seive(n):
	a = [1]
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p ** 2, n + 1, p):
				prime[i] = False
		p = p + 1
	for p in range(2, n + 1):
		if prime[p]:
			a.append(p)
	return a

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(M.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def countchar(s, i):
	c = 0
	ch = s[i]
	for i in range(i, len(s)):
		if s[i] == ch:
			c += 1
		else:
			break
	return c

def str_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q

def lis(arr):
	n = len(arr)
	lis = [1] * n
	maximum = 0
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] > arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
				maximum = max(maximum, lis[i])
	return maximum

def lcm(arr):
	a = arr[0]
	val = arr[0]
	for i in range(1, len(arr)):
		gcd = gcd(a, arr[i])
		a = arr[i]
		val *= arr[i]
	return val // gcd

def ncr(n, r):
	return M.factorial(n) // (M.factorial(n - r) * M.factorial(r))

def npr(n, r):
	return M.factorial(n) // M.factorial(n - r)

def inint():
	return int(inp())

def inarr():
	return list(map(int, inp().split()))

def invar():
	return map(int, inp().split())

def instr():
	s = inp()
	return list(s)

def insarr():
	return inp().split()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
inp = lambda : sys.stdin.readline().rstrip('\r\n')
TestCases = 0

def solve():
	s = inp()
	s += '$'
	n = len(s)
	res = ''
	c = 1
	seq = 0
	res = ''
	res += s[0]
	for i in range(1, n - 1):
		if s[i - 1] == s[i]:
			c += 1
		else:
			c = 1
		if c > 2:
			continue
		if res and seq and (s[i] == res[-1]):
			seq = 0
			continue
		if res and s[i] == res[-1] and (not seq):
			seq = 1
		if s[i] != s[i - 1] and s[i] != s[i + 1]:
			seq = 0
		res += s[i]
	print(res)

def main():
	flag = 0
	try:
		sys.stdin = open('c:/Users/Manoj Chowdary/Documents/python/CodeForces/contest-div-2/input.txt', 'r')
		sys.stdout = open('c:/Users/Manoj Chowdary/Documents/python/CodeForces/contest-div-2/output.txt', 'w')
	except:
		flag = 1
	t = 1
	if TestCases:
		t = inint()
	for _ in range(1, t + 1):
		solve()
	if not flag:
		print('Time: %.4f sec' % (time.time() - start_time))
		localtime = time.asctime(time.localtime(time.time()))
		print(localtime)
		sys.stdout.close()
main()


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


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
	elif ch[i] == ch[i + 1] and ch[i + 1] == ch[i + 2]:
		ch1 = ch1 + ch[i + 1] + ch[i + 2]
		i = i + 2
		verif = True
	elif ch[i] == ch[i + 1] and verif == True:
		ch1 = ch1 + ch[i]
		i = i + 1
		verif = False
	elif ch[i] == ch[i + 1]:
		ch1 = ch1 + ch[i] + ch[i + 1]
		verif = True
		i = i + 1
	else:
		ch1 = ch1 + ch[i]
		verif = False
	i = i + 1
print(ch1)


def main():
	s = input()
	l = ''
	ns = ''
	nb1 = 2
	inc = 0
	for x in range(len(s)):
		if s[x] != l:
			inc = 0
		if inc == 0:
			nb1 += 1
			ns += s[x]
		elif inc == 1 and nb1 >= 2:
			nb1 = 0
			ns += s[x]
		inc += 1
		l = s[x]
	print(ns)
main()


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)


a = ''
for x in input():
	if not (len(a) >= 2 and a[-1] == a[-2] == x or (len(a) >= 3 and a[-1] == x and (a[-2] == a[-3]))):
		a += x
print(a)


n = input()
ar = ['']
pair = 0
for i in n:
	if ar[-1] == i and pair == 0:
		ar.append(i)
		pair = 2
	elif ar[-1] != i:
		ar.append(i)
		if pair > 0:
			pair -= 1
s = ''
s += ''.join((i for i in ar if i != ''))
print(s)


s = input()
lt = []
for x in s:
	if len(lt) >= 2 and lt[-1] == lt[-2] == x or (len(lt) > 2 and lt[-3] == lt[-2] and (lt[-1] == x)):
		continue
	lt.append(x)
print(''.join(lt))


s = list(input())
pre = s[0]
ns = []
prec = 0
ns.append(pre)
posc = 1
for i in s[1:]:
	if i == pre:
		if prec != 2 and posc < 2:
			ns.append(i)
			posc += 1
			pre = i
	else:
		prec = posc
		posc = 1
		ns.append(i)
		pre = i
print(''.join(ns))


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:
			s += n[i]
			i += 1
	print(s[1:])


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)
				cnt = 1
			else:
				ans.append(s[i - 1])
				num.append(1)
		else:
			cnt += 1
		if i == len(s) - 1:
			cas.append(s[i])
			if cnt > 1:
				num.append(2)
				ans.append(s[i] + s[i])
			else:
				num.append(1)
				ans.append(s[i])
	for i in range(1, len(num)):
		if num[i] > 1 and num[i - 1] > 1:
			ans[i] = cas[i]
			num[i] -= 1
	print(''.join(ans))
s = list(input())
if len(s) > 1:
	fun(s)
else:
	print(''.join(s))


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 len(lst[i + 1]) > 1:
			lst[i + 1] = lst[i + 1][0]
if len(lst[len(lst) - 1]) > 2:
	lst[len(lst) - 1] = lst[len(lst) - 1][0] * 2
s1 = ''
for i in range(len(lst)):
	s1 += lst[i]
print(s1)


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:]
		break
	if ans[i] == ans[i + 1] and ans[i + 2] == ans[i + 3]:
		res += ans[i:i + 3]
		i += 4
	else:
		res += ans[i]
		i += 1
print(res)


s = input()
n = len(s)
if n == 1 or n == 2:
	print(s)
else:
	ans = [s[0], s[1]]
	for i in range(2, n):
		k = len(ans) - 1
		if s[i] != ans[k]:
			ans.append(s[i])
		elif ans[k] != ans[k - 1]:
			if k >= 2:
				if ans[k - 1] != ans[k - 2]:
					ans.append(s[i])
			else:
				ans.append(s[i])
	print(''.join(ans))


w = list(input())
a = ['@']
x = 0
y = 0
for s in w:
	if a[len(a) - 1] == s:
		if x < 2:
			if y <= 1:
				a.append(s)
				y += 1
		elif y == 0:
			a.append(s)
			y += 1
	else:
		x = y
		y = 0
		a.append(s)
		y += 1
a.pop(0)
print(''.join(a))


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest
sys.setrecursionlimit(111111)
INF = 99999999999999999999999999999999

def main():
	mod = 1000000007
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	tc = 1
	for _ in range(tc):
		s = rs()
		s += '.'
		temp = ''
		ans = []
		lwl2 = 0
		for i in range(len(s)):
			if len(temp) < 2:
				temp += s[i]
			if i + 1 < len(s) and s[i] != s[i + 1]:
				if lwl2 == 0:
					ans.append(temp)
					if len(temp) == 2:
						lwl2 = 1
				else:
					ans += temp[0]
					lwl2 = 0
				temp = ''
		ws(''.join(ans))
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


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[i])
print(''.join(stack))


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 s[i] != e:
		f = 0
		fs.append(s[i])
		l += 1
		e = s[i]
for i in range(len(fs)):
	print(fs[i], end='')


s = list(input())
a = ''
for x in s:
	if len(a) > 2 and a[-2] == a[-3] and (a[-1] == x) or (len(a) > 1 and a[-1] == a[-2] == x):
		continue
	a += x
print(a)


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])
				ans.append(string[i - 1])
				cnt = 2
			if cnt > 1 and prev_cnt == 2:
				ans.pop()
				cnt = 1
			prev_cnt = cnt
			cnt = 1
ch = string[-1]
if cnt == 1:
	ans.append(ch)
elif cnt == 2 or cnt >= 3:
	ans.append(ch)
	ans.append(ch)
if cnt > 1 and prev_cnt >= 2:
	ans.pop()
ans = ''.join(ans)
print(ans)


def main():
	from itertools import chain
	(s, l, z) = (input(), [], False)
	(a, b, f) = ('', s[0], l.append)
	u = v = 0
	for (i, c) in enumerate(chain(s, '+-')):
		if b == c:
			v += 1
		else:
			if z:
				z = False
			elif u > 1:
				z = True
				f(a)
			f(a)
			(u, v, a, b) = (v, 1, b, c)
	print(''.join(l))
main()


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2, floor, log
from bisect import bisect_right, bisect_left, bisect
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

def isPowerOfTwo(x):
	return x and (not x & x - 1)
MOD = 1000000007
PMOD = 998244353
N = 10 ** 6
LOGN = 30
alp = 'abcdefghijklmnopqrstuvwxyz'
T = 1
for _ in range(T):
	s = list(stdin.readline().strip('\n'))
	st = []
	for i in s:
		if len(st) < 2:
			st.append(i)
		else:
			if len(st) >= 3:
				if st[-3] == st[-2] and st[-1] == i:
					continue
			if st[-1] == i and st[-2] == i:
				continue
			else:
				st.append(i)
	for i in st:
		print(i, end='')
	print()


from collections import Counter
import itertools
from functools import lru_cache
import sys
import math

def helper():
	pass

def solve():
	s = input()
	n = len(s)
	ans = []
	i = 0
	while i < n:
		if i < n - 2 and s[i] == s[i + 1] == s[i + 2]:
			if len(ans) > 0 and ans[-1] == s[i]:
				ans += s[i]
			else:
				ans += s[i] * 2
			i += 3
		else:
			ans += s[i]
			i += 1
		j = len(ans) - 1
		if len(ans) >= 3:
			if ans[j] == ans[j - 1] == ans[j - 2]:
				ans.pop()
		j = len(ans) - 1
		if len(ans) >= 4:
			if ans[j] == ans[j - 1] and ans[j - 2] == ans[j - 3]:
				ans.pop()
	print(''.join(ans))
t = 1
for _ in range(t):
	solve()


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]
		if ct == 1:
			doub = False
		rep = False
		ct = 1
print(ans)


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 != ' ':
		print(i, end='')


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:
			print(l1[i][0])
		exit()
	if l1[i][1] == 1:
		print(l1[i][0], end='')
	elif l1[i][1] >= 2 and l1[i + 1][1] > 2:
		print(l1[i][0] * 2, end='')
		print(l1[i + 1][0], end='')
		i += 1
	elif l1[i][1] >= 2 and l1[i + 1][1] == 2:
		print(l1[i][0] * 2, end='')
		print(l1[i + 1][0], end='')
		i += 1
	elif l1[i][1] >= 2 and l1[i + 1][1] == 1:
		print(l1[i][0] * 2, end='')
	i += 1


import sys
import functools
sys.setrecursionlimit(100000)
s = sys.stdin.readline()
s_ = []
count = 0
for i in range(0, len(s)):
	if i < 2:
		s_.append(s[i])
		count += 1
	elif not s_[-1] == s_[-2] == s[i]:
		if not count < 3 and s_[-3] == s_[-2] and (s_[-1] == s[i]):
			pass
		else:
			s_.append(s[i])
			count += 1
print(''.join(s_))


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


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 range(1, len(a)):
	if a[i] != a[i - 1]:
		s += a[i]
res = ''
for i in range(len(b)):
	for j in range(b[i]):
		res += s[i]
print(res)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase

def main():
	(char, length) = (0, 1)
	string = input() + ' '
	fixedString = []
	previous = ['', 0]
	current = [string[0], 1]
	for i in range(1, len(string)):
		if string[i] != current[char]:
			if current[length] > 1:
				if previous[length] > 1:
					fixedString.append(current[char])
					current[length] = 1
				else:
					fixedString.extend([current[char]] * 2)
					current[length] = 2
			else:
				fixedString.append(current[char])
			previous[char] = current[char]
			previous[length] = current[length]
			current[char] = string[i]
			current[length] = 1
		else:
			current[length] += 1
	print(''.join(fixedString))
BUFFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
input = lambda : sys.stdin.readline().rstrip('\r\n')

def print(*args, **kwargs):
	sep = kwargs.pop('sep', ' ')
	file = kwargs.pop('file', sys.stdout)
	atStart = True
	for x in args:
		if not atStart:
			file.write(sep)
		file.write(str(x))
		atStart = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
main()


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 range(3, len(s)):
		if s[i] != l[-1]:
			l.append(s[i])
			c += 1
		elif l[-1] == l[-2] == s[i]:
			pass
		elif c >= 3 and l[-2] == l[-3] and (s[i] == l[-1]):
			pass
		else:
			l.append(s[i])
			c += 1
	print(''.join(l))


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
	elif x[i] == x[i - 1]:
		d[-1] += x[i]
		i += 1
	else:
		d.append(x[i])
		i += 1
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)


from sys import stdin
import math

def remove_three(string):
	mystack = ['-1']
	freq = 0
	for i in range(len(string)):
		if mystack[-1] == string[i]:
			freq += 1
			if freq == 3:
				freq -= 1
				continue
			else:
				mystack.append(string[i])
		else:
			mystack.append(string[i])
			freq = 1
	return mystack[1:]

def remove_two(string):
	mystack = [-1]
	index = []
	freq = 0
	for i in range(len(string)):
		if mystack[-1] == string[i]:
			freq += 1
			if freq == 2:
				index.append(i)
		else:
			freq = 1
		mystack.append(string[i])
	remove = []
	if len(index) > 0:
		last = index[0]
	for i in range(1, len(index)):
		if index[i] - last == 2:
			remove.append(index[i])
		else:
			last = index[i]
	remove.append(float('inf'))
	mystack = []
	j = 0
	for i in range(len(string)):
		if i == remove[j]:
			j += 1
			continue
		else:
			mystack.append(string[i])
	return mystack
string = list(stdin.readline().strip())
string = remove_three(string)
string = remove_two(string)
print(''.join(string))


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
from itertools import permutations
import heapq
I = sys.stdin.readline
alpha = 'abcdefghijklmnopqrstuvwxyz'
mod = 10 ** 9 + 7

def ii():
	return int(I().strip())

def li():
	return list(map(int, I().strip().split()))

def mi():
	return map(int, I().strip().split())

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def isPrime(n):
	if n <= 1:
		return False
	elif n <= 2:
		return True
	else:
		for i in range(2, int(n ** 0.5) + 1):
			if n % i == 0:
				return False
		return True

def main():
	s = I().strip()
	ans = []
	for i in s:
		if len(ans) > 1:
			if i != ans[-1] or i != ans[-2]:
				ans.append(i)
		else:
			ans.append(i)
	for i in range(len(ans)):
		if i > 2:
			if ans[i - 3] == ans[i - 2] and ans[i - 1] == ans[i]:
				ans[i] = '$'
	tmp = ''
	for i in ans:
		if i != '$':
			tmp += i
	print(tmp)
main()


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] != l[i + 2]) and (l[i] != '.'):
		l[i + 2] = '.'
		i += 2
	i += 1
l = [i for i in l if i != '.']
print(''.join(l))


s = input()
last = s[0]
final = []
i = 1
curr = 1
prev = 0
while i < len(s):
	if s[i] == last:
		curr += 1
	elif curr >= 2:
		if prev == 2:
			final.append(s[i - 1])
			prev = 1
			curr = 1
			last = s[i]
		else:
			final.append(s[i - 1])
			final.append(s[i - 1])
			prev = 2
			curr = 1
			last = s[i]
	else:
		final.append(s[i - 1])
		prev = 1
		curr = 1
		last = s[i]
	i += 1
if curr >= 2:
	if prev == 2:
		final.append(s[i - 1])
		prev = 1
		curr = 1
	else:
		final.append(s[i - 1])
		final.append(s[i - 1])
		prev = 2
		curr = 1
else:
	final.append(s[i - 1])
	prev = 1
	curr = 1
print(''.join(final))


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
s = is1()
res = ''
for i in s:
	if len(res) >= 2 and res[-1] == res[-2] == i:
		continue
	elif len(res) >= 3 and res[-1] == i:
		if res[-2] == res[-3]:
			continue
		else:
			res += i
	else:
		res += i
stdout.write(res + '\n')


l = input()
ans = ''
ct = []
i = 0
while i < len(l):
	t = l[i]
	c = 0
	while t == l[i]:
		i = i + 1
		c = c + 1
		if i == len(l):
			break
	if c == 1:
		ans = ans + t
		ct.append(c)
	else:
		if c >= 3:
			c = 2
		if len(ct) > 0:
			if c == 2 and ct[-1] == 2:
				c = 1
				ct.append(c)
				ans = ans + t * c
			else:
				ct.append(c)
				ans = ans + t * c
		else:
			ans = ans + t * c
			ct.append(c)
print(ans)


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)


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 + 3]:
			s.pop(i + 1)
			moved = True
		i -= 1
print(''.join(s))


import os
import sys
from io import BytesIO, IOBase
import math

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
import os
import sys
from io import BytesIO, IOBase

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
s = input()
n = len(s)
i = 1
cco = 1
cch = s[0]
ans = [s[0]]
if n == 1:
	print(s)
else:
	while i < n:
		if s[i] == cch:
			if cco < 2:
				if s[i] == cch:
					ans.append(s[i])
					cco += 1
		else:
			cco = 1
			cch = s[i]
			ans.append(s[i])
		i += 1
	i = 1
	ansf = []
	cdc = 0
	while i < len(ans):
		if ans[i] != ans[i - 1]:
			ansf.append(ans[i - 1])
			i += 1
			cdc = 0
		elif cdc == 1:
			ansf.append(ans[i])
			cdc = 0
			i += 2
		else:
			ansf.append(ans[i])
			ansf.append(ans[i - 1])
			cdc += 1
			i += 2
	if ans[-1] != ans[-2]:
		ansf.append(ans[-1])
	print(''.join(ansf))


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


s = input().strip()
arr = []
i = 0
while i < len(s):
	j = i
	cc = 0
	while j < len(s) and s[i] == s[j]:
		j += 1
		cc += 1
	arr.append([s[i], cc])
	i = j
pre = -1
ans = ''
for i in range(len(arr)):
	if pre == -1:
		pre = arr[i][1]
		ans += arr[i][0] * min(2, arr[i][1])
	elif pre > 1:
		ans += arr[i][0]
		pre = 1
	else:
		ans += arr[i][0] * min(2, arr[i][1])
		pre = arr[i][1]
print(ans)


s = list(input())
n = len(s)
a = [1] * n
prev = -1
cnt = 1
prev_cnt = 0
for i in range(n):
	if s[i] == prev:
		cnt += 1
	else:
		prev_cnt = cnt
		cnt = 1
	if prev_cnt < 2:
		if cnt >= 3:
			a[i] = 0
			cnt -= 1
	elif cnt >= 2:
		a[i] = 0
		cnt -= 1
	prev = s[i]
for i in range(n):
	if a[i]:
		print(s[i], end='')


s = input()
(pre, ls, ans, last) = ([s[0], 1], len(s), [s[0]], 0)
for i in range(1, ls):
	if s[i] == pre[0]:
		if last == 2 or pre[1] >= 2:
			continue
		else:
			ans.append(s[i])
			pre[1] += 1
	else:
		last = pre[1]
		pre = [s[i], 1]
		ans.append(s[i])
print(''.join(ans))


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()
			else:
				break
	print(''.join(r))
solve()


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()
t = s[0]
j = 0
b = []
for i in range(0, len(s)):
	if s[i] == t and j == 0:
		j = 1
		b.append(s[i])
	elif s[i] == t and j == 1:
		j = 2
		b.append(s[i])
	elif s[i] != t and j == 1:
		b.append(s[i])
	elif s[i] != t and j == 2:
		j = 3
		b.append(s[i])
	elif s[i] != t and j == 3:
		j = 1
		b.append(s[i])
	t = s[i]
print(*b, sep='')


string = input()
fixedString = ''
i = 0
if len(string) <= 2:
	print(string)
	exit(0)
while i < len(string):
	chain = 0
	j = i
	while string[j] == string[i]:
		j += 1
		chain += 1
		if j == len(string):
			j -= 1
			break
	if chain < 2:
		fixedString += string[i]
	elif chain == 2:
		fixedString += string[i] + string[i]
	if chain >= 3:
		fixedString += string[i:i + 2]
	i += chain
i = 0
string = fixedString
fixedString = ''
while i < len(string):
	j = i
	chain = 0
	if j < len(string) - 1:
		while string[j] == string[j + 1]:
			chain += 1
			j += 2
			if j >= len(string) - 1:
				break
	if chain == 0:
		fixedString += string[j]
	elif chain == 1:
		fixedString += string[j - 1] + string[j - 1]
	elif chain % 2 == 0:
		change = True
		for l in range(i, j, 2):
			if change:
				fixedString += string[l]
			else:
				fixedString += string[l] + string[l]
			change = not change
	else:
		change = False
		for l in range(i, j, 2):
			if change:
				fixedString += string[l]
			else:
				fixedString += string[l] + string[l]
			change = not change
	if chain == 0:
		i += 1
	i += chain * 2
print(fixedString)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return map(int, input().split())

def array():
	return [int(i) for i in input().split()]
s = input()
n = len(s)
i = 0
t = []
while i < n:
	c = 1
	while i + 1 < n and s[i] == s[i + 1]:
		c += 1
		i += 1
	t.append(s[i])
	if c > 1:
		t.append(s[i])
	i += 1
for i in range(0, len(t) - 4 + 1):
	if t[i] == t[i + 1] and t[i + 2] == t[i + 3]:
		t[i + 2] = -1
for i in t:
	if i != -1:
		print(i, end='')


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
		cur = 1
for i in range(n):
	if s[i] != -1:
		print(s[i], end='')
print()


from sys import stdin as sin

def aint():
	return int(sin.readline())

def amap():
	return map(int, sin.readline().split())

def alist():
	return list(map(int, sin.readline().split()))

def astr():
	return str(sin.readline().split())
from collections import defaultdict as dd
s = input()
n = len(s)
if n == 1:
	print(s)
else:
	ans = [s[0], s[1]]
	f = 0
	if s[0] == s[1]:
		f = 1
	for i in range(2, n):
		if s[i] == ans[-1] and s[i] == ans[-2]:
			pass
		elif s[i] == ans[-1]:
			if f == 0:
				ans.append(s[i])
				f = 1
		else:
			ans.append(s[i])
			if f == 1:
				f = 2
			else:
				f = 0
	print(''.join(ans))


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)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	s = si()
	a = ''
	l = []
	for i in range(len(s)):
		f = 0
		l = len(a)
		if l > 1 and s[i] == a[l - 1] and (a[-1] == a[l - 2]):
			f = 1
		elif l > 2 and s[i] == a[l - 1] and (a[l - 2] == a[l - 3]):
			f = 1
		if f == 0:
			a += s[i]
	print(a)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


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


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
	else:
		count = 0
		prev = 0
if len(s) == 1:
	s1 += s[0]
elif s[-1] != s[-2]:
	s1 += s[-1]
elif count >= 1 and prev == 0:
	s1 += s[-1]
print(s1)


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)


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


s = input()
l = ''
if len(s) <= 2:
	print(s)
elif len(s) <= 3:
	if s[0] == s[1] == s[2]:
		print(s[:2])
	else:
		print(s)
else:
	for i in range(len(s)):
		if i < 2:
			l += s[i]
		elif i == 2 and s[2] == s[1] and (s[1] != s[0]):
			l += s[i]
		elif l[-1] != s[i]:
			l += s[i]
		elif len(l) >= 3 and l[-1] == s[i] and (l[-2] != l[-3]) and (l[-2] != s[i]):
			l += s[i]
	print(l)


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


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) in enumerate(arr):
	if flag == 1:
		flag = 0
	elif j == 1:
		ans.append(strsarr[i])
	elif j >= 3 and i + 1 != n and (arr[i + 1] >= 2):
		ans.append(strsarr[i])
		ans.append(strsarr[i])
		ans.append(strsarr[i + 1])
		flag = 1
	elif j >= 3:
		ans.append(strsarr[i])
		ans.append(strsarr[i])
	elif j == 2 and i + 1 != n and (arr[i + 1] >= 2):
		ans.append(strsarr[i])
		ans.append(strsarr[i])
		ans.append(strsarr[i + 1])
		flag = 1
	else:
		for times in range(j):
			ans.append(strsarr[i])
print(''.join(ans))


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


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
	elif _c < 2 and _two == False:
		new = new + u
		g = u
		_c += 1
print(new)


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 st[i] == st[i - 1]:
		c += 1
	elif c == 2:
		if pre < 2:
			ans += st[i - 1] * c
			pre = c
			c = 1
		else:
			ans += st[i - 1]
			c = 1
			pre = 1
	else:
		ans += st[i - 1] * c
		pre = c
		c = 1
if c == 2:
	if pre < 2:
		ans += st[i - 1] * c
		pre = c
		c = 1
	else:
		ans += st[i - 1]
		c = 1
		pre = 1
else:
	ans += st[i]
print(ans)


import os, sys, math
from io import BytesIO, IOBase
from collections import defaultdict, deque, OrderedDict
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')

def I():
	return int(input())

def In():
	return map(int, input().split())

def ln():
	return list(map(int, input().split()))

def Sn():
	return input().strip()
BUFSIZE = 8192

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return len(a)

def solve():
	s = Sn()
	n = len(s)
	(an, frq) = ([], [])
	(last, cnt) = (s[0], 1)
	for x in s[1:]:
		if x != last:
			an.append(last)
			frq.append(min(cnt, 2))
			last = x
			cnt = 1
		else:
			cnt += 1
	an.append(last)
	frq.append(min(2, cnt))
	for i in range(len(frq) - 1):
		if frq[i] == 2 and frq[i + 1] == 2:
			frq[i + 1] = 1
	for i in range(len(an)):
		for j in range(frq[i]):
			print(an[i], end='')
	pass

def main():
	T = 1
	for i in range(T):
		solve()
M = 998244353
P = 1000000007

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


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


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] - seg[0] + 1 > 2:
			seg[1] = seg[0] + 1
	for i in range(len(segs) - 1):
		sega = segs[i]
		segb = segs[i + 1]
		if sega[1] - sega[0] + 1 == 2 and segb[1] - segb[0] + 1 == 2:
			segb[1] = segb[0]
	for seg in segs:
		stdout.write('{}'.format(seg[2] * (seg[1] - seg[0] + 1)))
	stdout.write('\n')
main(stdin.readline().strip())


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_freq, 2)
	if previous_freq == 2:
		current_freq = 1
	for _ in range(current_freq):
		ans.append(current_char)
	previous_freq = current_freq
print(''.join(ans))


import os, sys, heapq
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import ceil, remainder
mod = 10 ** 9 + 7
for _ in range(1):
	s = input()
	n = len(s)
	frequency_info = []
	count = 0
	for i in range(n):
		if not frequency_info:
			frequency_info.append([s[i], 1])
		elif s[i] != frequency_info[-1][0]:
			frequency_info.append([s[i], 1])
		elif frequency_info[-1][1] < 2:
			frequency_info[-1][1] += 1
	m = len(frequency_info)
	even = 0
	start = 0
	while start < m:
		if frequency_info[start][1] == 1:
			print(frequency_info[start][0], end='')
			start += 1
			continue
		else:
			even = 0
			while start < m and frequency_info[start][1] != 1:
				even += 1
				if even % 2 == 0:
					frequency_info[start][1] = 1
					print(frequency_info[start][0], end='')
				else:
					print(frequency_info[start][0] * 2, end='')
				start += 1


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[j])
	i = k
print(''.join(l))


s = input()
s1 = ''
for i in range(len(s)):
	if len(s1) > 1 and s[i] == s1[-1] and (s1[-1] == s1[-2]) or (len(s1) > 2 and s[i] == s1[-1] and (s1[-2] == s1[-3])):
		continue
	else:
		s1 += s[i]
print(s1)


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.append(i)
		elif len(a) >= 2:
			if a[-1] == i and a[-2] == i:
				continue
			else:
				a.append(i)
		else:
			a.append(i)
print(''.join(a))


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][1] < 2):
		stack.append([s[i], 2])
	elif s[i] != stack[-1][0]:
		stack.append([s[i], 1])
for i in stack:
	print(i[0], end='')


a = str(input())
l = list(a)
l1 = []
l1.append(l[0])
if len(l) == 1:
	print(l[0])
else:
	l1.append(l[1])
	for i in range(2, len(l)):
		if l1[-1] == l1[-2] == l[i] or (len(l1) > 2 and l1[-2] == l1[-3] and (l1[-1] == l[i])):
			continue
		else:
			l1.append(l[i])
	a = ''.join(l1)
	print(a)


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)


s = input()
stack = []
i = 0
n = len(s)
while i < n:
	if len(stack) < 2:
		stack.append(s[i])
		i += 1
	elif s[i] == stack[-1] == stack[-2]:
		i += 1
	elif len(stack) >= 3 and s[i] == stack[-1] and (stack[-2] == stack[-3]):
		i += 1
	else:
		stack.append(s[i])
		i += 1
print(''.join(stack))


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
					f(a)
				f(a)
				(u, v, a, b) = (v, 1, b, c)
	print(''.join(l))
main()


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 = len(string)
curr = 1
for i in range(1, length):
	if curr >= 2 and string[i] == ans[-1] and (string[i] == ans[-2]):
		continue
	elif curr >= 3 and string[i] == ans[-1] and (ans[-2] == ans[-3]):
		continue
	else:
		ans += string[i]
		curr += 1
print(ans)


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:
			hasDuplicates = True
		if count == 1:
			hasDuplicates = False
		count = 1
		printWord += word[i]
		doubleTest = word[i]
print(printWord)


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:
					array.append(2)
				else:
					array.append(count + 1)
				count = 0
		if count + 1 >= 3:
			array.append(2)
		else:
			array.append(count + 1)
		values += s[i]
		for i in range(1, len(array)):
			if array[i - 1] == 2 and array[i - 1] == array[i]:
				array[i] = 1
		new_array = [values[i] * array[i] for i in range(len(array))]
		print(''.join(new_array))
s = input()
fixing_typos(s)


def STR():
	return list(input())

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def MAP2():
	return map(float, input().split())

def LIST():
	return list(map(int, input().split()))

def STRING():
	return input()
import string
import sys
from heapq import heappop, heappush, heapify
from bisect import *
from collections import deque, Counter, defaultdict
from math import *
from itertools import permutations, accumulate
dx = [-1, 1, 0, 0]
dy = [0, 0, 1, -1]
s = STRING()
s = list(s)
a = [1] * len(s)
x = s[0]
for i in range(1, len(a)):
	if s[i] == s[i - 1]:
		a[i] = a[i - 1] + 1
	if a[i] > 2:
		continue
	else:
		x += s[i]
s = list(x)
a = [1] * len(s)
x = s[0]
last = 1
c = 1
for i in range(1, len(a)):
	if x[-1] != s[i]:
		x += s[i]
		c += 1
		if c >= 2:
			last = 1
	elif x[-1] == s[i] and last < 2:
		x += s[i]
		last = 2
		c = 0
	elif x[-1] == s[i] and last >= 2:
		continue
print(x)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass
s = input()
x = []
i = 0
while i < len(s):
	k = 0
	while i + k < len(s) and s[i] == s[i + k]:
		k += 1
	x.append(s[i:i + k])
	i += k
count = 0
for i in range(len(x)):
	if len(x[i]) > 2:
		count += len(x[i]) - 2
		x[i] = x[i][:2]
	if i - 1 >= 0 and len(x[i - 1]) == 2 and (len(x[i]) == 2):
		count += 1
		x[i] = x[i][:1]
print(''.join(x))
endtime = time.time()


s = list(input())
n = len(s)
cnt = 0
prev = s[0]
ans = []
chk = False
for x in range(n):
	if s[x] == prev:
		cnt += 1
	else:
		if cnt == 1:
			ans.append(s[x - 1])
			chk = False
		elif cnt >= 2 and chk:
			ans.append(s[x - 1])
			chk = False
		elif cnt >= 2 and chk == False:
			chk = True
			ans.append(s[x - 1])
			ans.append(s[x - 1])
		cnt = 1
	prev = s[x]
x = n
if cnt == 1:
	ans.append(s[x - 1])
	chk = False
elif cnt >= 2 and chk:
	ans.append(s[x - 1])
elif cnt >= 2 and chk == False:
	chk = True
	ans.append(s[x - 1])
	ans.append(s[x - 1])
print(*ans, sep='')


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[1][1], 2) * lis[1][0]
if len(ans) == 4:
	ans = ans[:3]
	lis[1][1] = 1
else:
	lis[1][1] = min(lis[1][1], 2)
for i in range(2, len(lis)):
	if lis[i][1] > 1:
		if lis[i - 1][1] == 2:
			ans += lis[i][0]
			lis[i][1] = 1
		else:
			ans += min(lis[i][1], 2) * lis[i][0]
			lis[i][1] = min(lis[i][1], 2)
	elif lis[i - 1][1] == 2:
		ans += lis[i][0]
		lis[i][0] = 1
	else:
		ans += min(lis[i][1], 2) * lis[i][0]
		lis[i][1] = min(lis[i][1], 2)
print(ans)


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)


import sys
import collections
from collections import Counter
import itertools
import math
import timeit

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)
s = input()
d = [i for i in s]
if len(d) < 2:
	exit(print(s))
ans = [d[0], d[1]]
i = 2
while i < len(d):
	if ans[-2] == ans[-1] == d[i]:
		i += 1
		continue
	if len(ans) > 2 and ans[-3] == ans[-2] and (ans[-1] == d[i]):
		i += 1
		continue
	ans.append(d[i])
	i += 1
prr(ans, sep='')


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)


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[i], end='')


(s, t) = (input(), 1)
k = list(s)
for i in range(1, len(s)):
	t = t + 1 if s[i] == s[i - 1] else 1
	if t > 2:
		k[i] = '|'
k = ''.join(k).replace('|', '') + '||'
(t, k) = (0, list(k))
for i in range(1, len(k)):
	if k[i] == k[i - 1] and t:
		t = 0
		k[i] = '|'
	if k[i] == k[i - 1]:
		t = 1
	elif k[i] != k[i + 1]:
		t = 0
k = ''.join(k).replace('|', '')
print(k)


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] == last:
		bre = 0
		c += 1
		if c == 2:
			cc += 1
			if cc == 2:
				dele.append(i)
				cc = 0
	else:
		if bre:
			cc = 0
		last = s[i]
		c = 1
		bre = 1
for ind in dele[::-1]:
	del s[ind]
print(''.join(s))


s = input()
z = []
count = 1
for i in range(len(s)):
	z.append(s[i])
i = 1
while i < len(z):
	if s[i] == s[i - 1]:
		count = count + 1
	else:
		if count >= 3:
			kap = 0
			while count > 2:
				z[i - kap - 1] = -1
				kap = kap + 1
				count = count - 1
		count = 1
	i = i + 1
if count >= 3:
	kap = 0
	while count > 2:
		z[i - kap - 1] = -1
		kap = kap + 1
		count = count - 1
z = list(filter(lambda a: a != -1, z))
for i in range(3, len(z)):
	if z[i] == z[i - 1] and z[i - 2] == z[i - 3]:
		z[i] = -1
z = list(filter(lambda a: a != -1, z))
print(''.join(map(str, z)))


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(s[i])
		a.append(s[i])
		k = 0
		continue
	a.append(s[i])
b = []
i = 0
while i < len(a) - 3:
	if a[i] == a[i + 1] and a[i + 2] == a[i + 3]:
		b.append(a[i])
		b.append(a[i + 1])
		b.append(a[i + 2])
		i = i + 4
		continue
	b.append(a[i])
	i = i + 1
h = i
for j in a[h:]:
	b.append(j)
ans = ''
ans = ans.join(b)
print(ans)


s = input()
ans = []
index_shift = 0
for (i, si) in enumerate(s):
	ans.append(si)
	if i >= 2:
		if s[i - 2] == s[i - 1] == si:
			ans.pop(i - index_shift)
			index_shift += 1
		elif i >= 3:
			if ans[i - 3 - index_shift] == ans[i - 2 - index_shift] and ans[i - 1 - index_shift] == si:
				ans.pop(i - index_shift)
				index_shift += 1
print(''.join(ans))


import sys
t = 1
for __ in range(t):
	s1 = input()
	ans = []
	ch = 4
	for i in range(len(s1)):
		if i <= len(s1) - 3:
			if s1[i] == s1[i + 1] == s1[i + 2]:
				continue
		if i <= len(s1) - 2:
			if s1[i] == s1[i + 1]:
				if ch != -1:
					ans.append(s1[i])
					ch = 4
				else:
					continue
				ch = -2
			else:
				ans.append(s1[i])
				if ch == -2:
					ch += 1
				else:
					ch = 4
	ans.append(s1[-1])
	print(''.join(ans))


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


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:
	if li1[i] == li1[i - 1] and fl == 1:
		g.append(i)
		fl = 0
	elif li1[i] == li1[i - 1]:
		fl = 1
		i += 1
	elif li1[i] != li1[i - 1] and fl == 1:
		fl = 0
	i += 1
li2 = []
k = 0
for i in range(n):
	if k < len(g) and i == g[k]:
		k += 1
	else:
		li2.append(li1[i])
print(''.join(li2))


__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))
main()


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from functools import lru_cache
from collections import Counter
sys.setrecursionlimit(100000000)
int_r = lambda : int(sys.stdin.readline())
str_r = lambda : sys.stdin.readline().strip()
intList_r = lambda : list(map(int, sys.stdin.readline().strip().split()))
strList_r = lambda : list(sys.stdin.readline().strip())
jn = lambda x, l: x.join(map(str, l))
mul = lambda : map(int, sys.stdin.readline().strip().split())
mulf = lambda : map(float, sys.stdin.readline().strip().split())
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
outStr = lambda x: stdout.write(str(x))
mod = 1000000007

def main():
	s = str_r()
	ctr = list()
	prev = s[0]
	ctr.append([s[0], 1])
	inde = 0
	for i in range(1, len(s)):
		if prev == s[i]:
			ctr[inde] = [ctr[inde][0], ctr[inde][1] + 1]
		else:
			ctr.append([s[i], 1])
			prev = s[i]
			inde += 1
	ctr = [[c, 2] if v > 2 else [c, v] for (c, v) in ctr]
	i = 0
	while i < len(ctr) - 1:
		if ctr[i][1] == 2 and ctr[i + 1][1] == 2:
			ctr[i + 1][1] = 1
			i += 1
		i += 1
	str = ''
	for (c, v) in ctr:
		for i in range(v):
			str = str + c
	outStr(str)
main()


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:
			wordCorrected += typoWord[i]
			i -= 1
	while i >= 0:
		wordCorrected += typoWord[i]
		i -= 1
	return wordCorrected[::-1]

def correctTypo3(typoWord):
	wordCorrected = ''
	i = 0
	while i < len(typoWord) - 2:
		if typoWord[i] == typoWord[i + 1] and typoWord[i + 1] == typoWord[i + 2]:
			wordCorrected += typoWord[i] + typoWord[i + 1]
			i += 3
		else:
			wordCorrected += typoWord[i]
			i += 1
	while i < len(typoWord):
		wordCorrected += typoWord[i]
		i += 1
	return wordCorrected

def correctTypo(typoWord):
	corrected = correctTypo3(typoWord)
	while len(corrected) < len(typoWord):
		typoWord = corrected
		corrected = correctTypo3(typoWord)
	return correctTypo22(corrected)

def main():
	f = sys.stdin
	print(correctTypo(f.readline()))
main()


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) - 1] == s[i]):
		continue
	else:
		ans += s[i]
print(ans)


def fixing_typos(s):
	s = list(s)
	ans = [s[0]]
	i = 1
	double = False
	triple = False
	while i < len(s):
		if s[i] == ans[-1]:
			if triple:
				i += 1
				continue
			if double:
				i += 1
				continue
			triple = True
		else:
			double = triple
			triple = False
		ans.append(s[i])
		i += 1
	return ''.join(ans)
s = input().strip()
print(fixing_typos(s))


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)


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] == string[cnt + 3]:
			string[cnt + 2] = ''
		cnt += 1
except IndexError:
	pass
print(*string, sep='')


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 letters[-2][1] == 2 and letters[-1][1] == 2:
					letters[-1][1] = 1
					ans += 1
			letters.append([s[i], 1])
			curr = s[i]
	if len(letters) > 1:
		if letters[-2][1] == 2 and letters[-1][1] == 2:
			letters[-1][1] = 1
			ans += 1
	new = ''
	for i in letters:
		new += i[0] * i[1]
	print(new)
main()


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
s = list(input())
n = len(s)
ans = []
for i in range(n):
	if len(ans) >= 2 and ans[-1] == ans[-2] == s[i] or (len(ans) > 2 and ans[-3] == ans[-2] and (ans[-1] == s[i])):
		continue
	ans.append(s[i])
print(''.join(ans))


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


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
s = inp()
ml = []
n = len(s)
for i in range(n):
	if len(ml) > 1 and s[i] == ml[-1] == ml[-2]:
		continue
	elif len(ml) > 2 and s[i] == ml[-1] and (ml[-2] == ml[-3]):
		continue
	else:
		ml.append(s[i])
print(''.join(ml))


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]:
		if l[i - 1] == 0:
			if i - 2 >= 0 and l[i - 2] == 1:
				l[i] = -1
			else:
				l[i] = 1
ans = ''
for i in range(len(t)):
	if l[i] != -1:
		ans += t[i]
print(ans)


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]:
		if ln[j - 1] != ln[j - 2] or i == l - 1 or s[i] != s[i + 1]:
			ln.append(s[i])
			j += 1
print(''.join(ln))


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 >= 2:
			dic[i] = 1
		elif c > 2:
			dic[i] = 1
	ans = ''
	for i in range(len(s)):
		if i not in dic:
			ans = ans + s[i]
	print(ans)


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 else [x[0], 2], sans))
for i in range(len(sans) - 1):
	if sans[i][1] == 2 and sans[i + 1][1] == 2:
		sans[i + 1][1] = 1
print(''.join(map(lambda x: x[0] * x[1], sans)))


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


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = 1
	rr = []
	for _ in range(t):
		s = S()
		t = []
		b = ''
		u = 0
		for c in s:
			if b != c:
				if u > 0:
					t.append([b, min(2, u)])
				b = c
				u = 1
			else:
				u += 1
		t.append([b, min(2, u)])
		for i in range(1, len(t)):
			if t[i][1] > 1 and t[i - 1][1] > 1:
				t[i][1] = 1
		r = []
		for (b, u) in t:
			r.append(b * u)
		rr.append(JA(r, ''))
	return JA(rr, '\n')
print(main())


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


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


import collections as cc
import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
s = input()
ans = ''
for i in s:
	if len(ans) > 2 and ans[-2] == ans[-3] and (ans[-1] == i):
		continue
	elif len(ans) > 1 and ans[-1] == ans[-2] == i:
		continue
	ans += i
print(ans)


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[0][0] >= 3:
	g[-1][0] = 2
ans = ''
for i in g:
	for j in range(i[0]):
		print(i[1], end='')


t = ''
x = input()
for i in x:
	if not (len(t) >= 2 and t[-1] == t[-2] == i or (len(t) >= 3 and t[-1] == i and (t[-2] == t[-3]))):
		t = t + i
print(t)


s = input()
st = []
for c in s:
	if len(st) > 2 and st[-2] == st[-3] and (st[-1] == c):
		continue
	if len(st) > 1 and st[-1] == st[-2] == c:
		continue
	st.append(c)
print(''.join(st))


import sys
a = ''
for x in sys.stdin.readline().strip():
	if not (len(a) >= 2 and a[-1] == a[-2] == x or (len(a) >= 3 and a[-1] == x and (a[-2] == a[-3]))):
		a += x
print(a)


MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
s = input()
res = ''
d = []
n = len(s)
if n < 3:
	print(s)
else:
	res += s[:3]
	i = 3
	j = 2
	if res[j] == res[j - 1] and res[j - 1] == res[j - 2]:
		res = res[:j]
		j -= 1
	while i < n:
		res += s[i]
		i += 1
		j += 1
		if j >= 2 and res[j] == res[j - 1] and (res[j - 1] == res[j - 2]):
			res = res[:j]
			j -= 1
		if j >= 3 and res[j] == res[j - 1] and (res[j - 2] == res[j - 3]):
			res = res[:j]
			j -= 1
	print(''.join(res))


import sys
s = list(input())
n = len(s)
if n <= 2:
	print(''.join(s))
	sys.exit()
temp = ['/', s[0], s[1]]
for i in range(2, n):
	if s[i] == temp[-1] and s[i] == temp[-2]:
		continue
	elif temp[-2] == temp[-3] and s[i] == temp[-1]:
		continue
	else:
		temp.append(s[i])
x = ''.join(temp[1:])
print(x)


import math
from decimal import *
import random
mod = int(1000000000.0) + 7
s = list(input())
ans = [s[0]]
cnt = 1
tp = 0
for i in range(1, len(s)):
	if s[i] == s[i - 1]:
		cnt += 1
	elif cnt == 3 and tp == 1:
		cnt = 1
		ans.append(s[i])
		tp = 0
		pass
	elif cnt == 3 and tp == 0:
		ans.append(s[i - 1])
		cnt = 1
		ans.append(s[i])
		tp = 1
	elif cnt >= 2 and tp == 0:
		ans.append(s[i - 1])
		ans.append(s[i])
		tp = 1
		cnt = 1
	elif cnt >= 2 and tp == 1:
		ans.append(s[i])
		tp = 0
		cnt = 1
	else:
		ans.append(s[i])
		tp = 0
		cnt = 1
if cnt == 3 and tp == 0:
	ans.append(s[-1])
elif cnt >= 2 and tp == 0:
	ans.append(s[-1])
print(''.join(ans))


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)):
				self.string.append(self.prev[ii])
			self.prev = self.current
			self.current = [char]
		elif len(self.current) == 2:
			pass
		elif len(self.prev) == 2:
			pass
		else:
			self.current.append(char)

	def getString(self):
		return [self.string, self.prev, self.current]

def main():
	string = input()
	goodString = GoodString()
	for i in range(len(string)):
		goodString.appendChar(string[i])
	sol = goodString.getString()
	for i in range(len(sol)):
		for j in range(len(sol[i])):
			print(sol[i][j], end='')
main()


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


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 ''.join(r)
	ans = r[:3]
	i = 3
	while i < len(r):
		if ans[-3] == ans[-2] and ans[-1] == r[i]:
			i += 1
			continue
		else:
			ans.append(r[i])
			i += 1
	return ''.join(ans)
s = str(input())
i = 0
print(f(s))


__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()
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 to_be_removed:
	s[i] = ''
s = ''.join(s)
islands_of_2 = []
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 == 2:
			islands_of_2.append(i)
	else:
		cur_char = c
		cur_char_cnt = 1
if islands_of_2:
	island_to_remove = []
	prev_island = None
	for island in islands_of_2:
		if prev_island and prev_island + 2 == island:
			island_to_remove.append(island)
			prev_island = None
			continue
		else:
			prev_island = island
	s = [c for c in s]
	for i in island_to_remove:
		s[i] = ''
print(''.join(s))


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


s = input()
i = 0
n = len(s)
l = []
while i < n:
	cnt = s[i]
	while i + 1 < n and s[i] == s[i + 1]:
		cnt += s[i + 1]
		i += 1
	l.append(cnt)
	i += 1
for i in range(len(l)):
	if len(l[i]) > 2:
		l[i] = l[i][:2]
(ans1, t1) = ('', 0)
for i in l:
	if len(i) == 2:
		if t1:
			ans1 += i[0]
			t1 = 0
		else:
			ans1 += i
			t1 = 1
	else:
		ans1 += i
		t1 = 0
print(ans1)


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


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())
from itertools import *
s = si()
l = []
lch = []
for (i, j) in groupby(s):
	l.append(len(list(j)))
	lch.append(i)
n = len(l)
if l[0] >= 3:
	l[0] = 2
for i in range(1, n):
	if l[i] >= 3:
		l[i] = 2
	if l[i - 1] == 2 and l[i] == 2:
		l[i] = 1
for (i, j) in zip(l, lch):
	print(j * i, end='')


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(True)
			inc.append(1)
		else:
			dp.append(False)
			inc.append(1)
	for i in range(2, n):
		if s[i] == s[i - 1]:
			dp.append(True)
			if dp[i - 1] == True or dp[i - 2] == True:
				inc.append(0)
				if s[i - 1] != s[i] or s[i - 1] != s[i - 2]:
					dp[-1] = False
			else:
				inc.append(1)
		else:
			dp.append(False)
			inc.append(1)
	ans = ''
	for i in range(n):
		if inc[i] == 1:
			ans += s[i]
	print(ans)


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[i]
			cnt += 1
	else:
		ans += s[i]
		cnt = 1
final = list(ans)
n = len(final)
(c1, c2, n1, n2) = (0, 1, 2, 3)
while c1 < n and c2 < n and (n1 < n) and (n2 < n):
	if final[c1] == final[c2] and final[n1] == final[n2]:
		final[n2] = -1
		c1 += 4
		c2 += 4
		n1 += 4
		n2 += 4
	else:
		c1 += 1
		c2 += 1
		n1 += 1
		n2 += 1
print(''.join([i for i in final if i != -1]))
if FILE_POINTER:
	FILE_POINTER.close()


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.start = Node(s[0])
		node = self.start
		for (i, el) in enumerate(s[1:]):
			node.next = Node(el, i + 1, previous=node)
			node = node.next

	def __str__(self):
		node = self.start
		s = ''
		while node:
			s += node.value
			node = node.next
		return s
linkedlist = LL()
linkedlist.from_str(s)
if linkedlist.start is not None and linkedlist.start.next is not None and (linkedlist.start.next.next is not None):
	node = linkedlist.start.next.next
else:
	node = None
while node:
	if node.previous.value == node.previous.previous.value == node.value:
		node.previous.next = node.next
		if node.next is not None:
			node.next.previous = node.previous
	elif node.previous.previous.previous is not None and node.previous.previous.previous.value == node.previous.previous.value and (node.previous.value == node.value):
		node.previous.next = node.next
		if node.next is not None:
			node.next.previous = node.previous
	node = node.next
print(linkedlist)


s = input()
arr = []
for i in range(len(s)):
	if i > 1:
		if s[i] == arr[-1] and arr[-2] == arr[-1]:
			continue
	if i > 2:
		if s[i] == arr[-1] and arr[-2] == arr[-3]:
			continue
	arr.append(s[i])
print(''.join(arr))


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]
		i += 4
	else:
		j += s[i]
		i += 1
print(j)


a = input()
n = len(a)
if n <= 2:
	print(a)
else:
	res = ''
	a += '_'
	n = len(a)
	i = 0
	mode = 0
	while i < n - 1:
		c = 1
		while i < n - 1 and a[i] == a[i + 1]:
			c += 1
			i += 1
		if c == 1:
			res += a[i]
			mode = 0
		elif mode == 1:
			mode = 0
			res += a[i]
		else:
			res += 2 * a[i]
			mode = 1
		i += 1
	print(res)


def main():
	from sys import stdin, stdout
	ip = stdin.readline().strip()
	t = ip[0]
	for ch in ip[1:]:
		if len(t) > 2:
			if ch == t[-1] and t[-2] == t[-3] or (ch == t[-1] and t[-1] == t[-2]):
				continue
			else:
				t += ch
		elif len(t) == 2:
			if ch == t[-1] and ch == t[-2]:
				continue
			else:
				t += ch
		else:
			t += ch
	stdout.write(t)
main()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import Counter
import sys
import math
from math import gcd
import sys
s = sys.stdin.readline()
ans = []
l = 0
for i in s:
	if l >= 2 and ans[-1] == ans[-2] == i or (l > 2 and ans[-2] == ans[-3] and (ans[-1] == i)):
		continue
	ans.append(i)
	l += 1
print(''.join(ans))


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)


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:
		C[0] = 2
	for i in range(1, len(B)):
		if C[i] > 2:
			C[i] = 2
		if C[i - 1] == 2:
			C[i] = 1
	A = []
	for i in range(len(B)):
		for c in range(C[i]):
			A.append(B[i])
	print(''.join(A))
n = input()
correct(list(n))


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:
			flag = 2
	elif s[i] != s[i - 1] and flag == 2:
		flag = 0
	elif s[i] == s[i - 1] and flag == 2:
		s[i - 1] = ''
		flag = 3
print(*s, sep='')


s = input()
ans = []
p_count = c_count = 0
p_char = c_char = ''
d_used = False
for c in s:
	if c == c_char:
		c_count += 1
		if c_count <= 2:
			if c_count == 2 and p_count >= 2:
				continue
			if c_count == 2:
				d_used = True
			ans.append(c)
	else:
		if d_used:
			p_count = min(2, c_count)
			d_used = False
		else:
			p_count = 1
		c_count = 1
		c_char = c
		ans.append(c)
print(''.join(ans))


from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
from collections import defaultdict as dd, deque

def data():
	return sys.stdin.readline().strip()

def mdata():
	return map(int, data().split())
mod = int(1000000000.0 + 7)
s = input()
s1 = s[0]
k = 0
for i in range(1, len(s)):
	if s[i] == s[i - 1]:
		if k == 0:
			s1 += s[i]
			k = 1
	else:
		k = 0
		s1 += s[i]
s = s1[0]
k = 0
for i in range(1, len(s1)):
	if s1[i] == s1[i - 1]:
		if k == 0:
			s += s1[i]
			k = i
		elif i - k != 2:
			k = i
			s += s1[i]
		else:
			k = 0
	else:
		s += s1[i]
print(s)


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):
				print(lastVal, end='')
			lastPlat = curPlat
			curPlat = 1
		lastVal = c
main()


s = input()
ans = ''
l = 0
for i in s:
	tr = True
	if l > 1:
		if i == ans[l - 1] and ans[l - 1] == ans[l - 2]:
			tr = False
	if l > 2:
		if i == ans[l - 1] and ans[l - 2] == ans[l - 3]:
			tr = False
	if tr:
		ans += i
		l += 1
print(ans)


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
		first = True
	i += d
print(ans)


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:
			arr[i] = 1
		flag = 0
	i += it
for i in range(len(str)):
	arr[i] = min(arr[i], 2)
ret = ''
i = 0
while i < len(str):
	for j in range(arr[i]):
		ret += str[i]
	i += max(1, arr[i])
print(ret)


s = input()

def encode(s):
	enc = []
	i = 0
	n = len(s)
	curChar = s[i]
	count = 0
	while i < n:
		if s[i] == curChar:
			count += 1
		else:
			enc.append(curChar)
			enc.append(count)
			curChar = s[i]
			count = 1
		i += 1
	enc.append(curChar)
	enc.append(count)
	return enc

def decode(s):
	a = ''
	for i in range(0, len(s), 2):
		p = s[i] * s[i + 1]
		a += p
	return a
e = encode(s)
i = 0
n = len(e)
while i < n - 1:
	if e[i + 1] > 2:
		e[i + 1] = 2
	i += 2
i = 2
while i < n:
	if e[i + 1] > 1 and e[i - 1] > 1:
		e[i + 1] = 1
		i += 2
	else:
		i += 2
ans = decode(e)
print(ans)


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)


s = input()
n = len(s)
x = []
for i in range(n):
	if i > 1:
		if s[i] == x[-1] and x[-2] == x[-1]:
			continue
	if i > 2:
		if s[i] == x[-1] and x[-2] == x[-3]:
			continue
	x.append(s[i])
print(''.join(x))


import os
import sys
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def seive(n):
	primes = [True] * (n + 1)
	for i in range(2, n):
		if not primes[i]:
			continue
		j = 2 * i
		while j <= n:
			primes[j] = False
			j += i
	return primes

def factors(n):
	factors = []
	x = 2
	while x * x <= n:
		while n % x == 0:
			factors.append(x)
			n //= x
		if n > 1:
			factors.append(x)
	return factors

def main():
	try:
		s = list(input())
		n = len(s)
		ans = s[:min(2, n)]
		if n > 2:
			i = 2
			while i < n:
				if not s[i] == ans[-1] == ans[-1 - 1] and (not (i - 3 >= 0 and len(ans) > 2 and (s[i] == ans[-1]) and (ans[-1 - 1] == ans[-1 - 2]))):
					ans += [s[i]]
				i += 1
		print(''.join(ans))
	except Exception as e:
		print(e)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()