Reduce a string of lowercase characters in range ascii[‘a’..’z’]by doing a series of operations.  In each operation, select a pair of adjacent letters that match, and delete them.  

Delete as many characters as possible using this method and return the resulting string.  If the final string is empty, return Empty String

Example. 

$s=\text{'aab'}$  

aab shortens to b in one operation: remove the adjacent a characters. 

$s=\text{'aba'}$  

Remove the two 'b' characters leaving 'aa'.  Remove the two 'a' characters to leave ''.  Return 'Empty String'.

Function Description

Complete the superReducedString function in the editor below.   

superReducedString has the following parameter(s):  

string s: a string to reduce  

Returns  

string: the reduced string or Empty String  

Input Format

A single string, $\boldsymbol{\mathrm{~S~}}$.

Constraints

$1\leq\ \text{length of}\ s\leq100$

Sample Input 0
aaabccddd

Sample Output 0
abd

Explanation 0

Perform the following sequence of operations to get the final string:

aaabccddd → abccddd → abddd → abd

Sample Input 1
aa

Sample Output 1
Empty String

Explanation 1
aa → Empty String

Sample Input 2
baab

Sample Output 2
Empty String

Explanation 2
baab → bb → Empty String

Difficulty: EASY
Tags: String algorithms

Starter code:

Solutions:
s = input()
while True:
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			s = s[:i] + s[i + 2:]
			break
	else:
		break
print(s if s else 'Empty String')


s = str(input())
n = len(s)
L = [s[i] for i in range(n)]
ok = 1
while ok:
	ok = 0
	for i in range(1, len(L)):
		if L[i] == L[i - 1]:
			del L[i]
			del L[i - 1]
			ok = 1
			break
for i in range(len(L)):
	print(L[i], end='')
if L == []:
	print('Empty String')


n = input().strip()
x = 0
while x + 1 < len(n):
	if n[x] == n[x + 1]:
		n = n[:x] + n[x + 2:]
		if x > 0:
			x -= 1
	else:
		x += 1
if n == '':
	print('Empty String')
else:
	print(n)


s = input()
while True:
	ns = s
	for l in 'abcdefghijklmnopqrstuvwxyz':
		ns = ns.replace(l + l, '')
	if len(ns) == len(s):
		break
	s = ns
print(s if len(s) > 0 else 'Empty String')


import sys

def posReductible(chaine):
	courant = chaine[0]
	pos = 0
	for c in chaine[1:]:
		if c == courant:
			return pos
		courant = c
		pos += 1

def estReductible(chaine):
	if chaine == '':
		return False
	courant = chaine[0]
	for c in chaine[1:]:
		if c == courant:
			return True
		courant = c
	return False
chaineCourante = str(input())
while estReductible(chaineCourante):
	pos1 = posReductible(chaineCourante)
	chaineCourante = chaineCourante[0:pos1] + chaineCourante[pos1 + 2:]
if chaineCourante == '':
	print('Empty String')
else:
	print(chaineCourante)


def main():
	string = input()
	result = solve(string)
	if not result:
		print('Empty String')
	else:
		print(result)

def solve(string):
	while string:
		modified = False
		for i in range(len(string) - 1):
			if string[i] == string[i + 1]:
				string = string[:i] + string[i + 2:]
				modified = True
				break
		if not modified:
			return string
	return string
main()


s = list(input())

def op(l):
	i = 0
	while i < len(l):
		if i + 1 < len(l) and l[i] == l[i + 1]:
			i += 2
		else:
			yield l[i]
			i += 1
while True:
	s0 = list(op(s))
	if s0 == []:
		print('Empty String')
		break
	elif s0 == s:
		print(''.join(s0))
		break
	s = s0


temp = ''
s = input()
while temp != s:
	temp = s
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			s = s[:i] + s[i + 2:]
			break
print('Empty String' if len(s) == 0 else s)


import sys
a = list(input())
changed = True
while changed:
	changed = False
	for i in range(len(a) - 1):
		if i + 1 < len(a) and a[i] == a[i + 1]:
			changed = True
			del a[i + 1]
			del a[i]
print('Empty String' if len(a) == 0 else ''.join(a))


s = input()
finished = False
foundmatch = False
while not finished:
	if len(s) <= 1:
		break
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			foundmatch = True
			break
	if foundmatch:
		if len(s) == 2:
			s = ''
			finished = True
		else:
			s = s[:i] + s[i + 2:]
		foundmatch = False
	else:
		finished = True
if len(s) == 0:
	print('Empty String')
else:
	print(s)


import re
s = input()
while s != re.sub('(\\w)\\1', '', s):
	s = re.sub('(\\w)\\1', '', s)
print(s if s else 'Empty String')


s = input()
l = list(s)
for i in l:
	s = s.replace(i * 2, '')
if s == '':
	print('Empty String')
else:
	print(s)


def chunks(l, n):
	for i in range(0, len(l), n):
		yield l[i:i + n]

def reduce(s):
	if s == '':
		return s
	s1 = ''.join((''.join(x) for x in chunks(s, 2) if len(x) != 2 or x[0] != x[1]))
	if s1 != s:
		return reduce(s1)
	s1 = s[0] + ''.join((''.join(x) for x in chunks(s[1:], 2) if len(x) != 2 or x[0] != x[1]))
	if s1 != s:
		return reduce(s1)
	return s

def main():
	s = input()
	print(reduce(s) or 'Empty String')
main()


s = list(input().strip())
while True:
	start = len(s)
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			s[i] = s[i + 1] = None
	s = [x for x in s if x is not None]
	if start == len(s):
		break
if s:
	print(''.join(s))
else:
	print('Empty String')


def reduce_str(str):
	for i in range(len(str)):
		if str[i:i + 2] == str[i] * 2:
			return reduce_str(str[:i] + str[i + 2:])
	if str == '':
		return 'Empty String'
	else:
		return str
print(reduce_str(input()))


s = input()
changed = True
while changed and s != '':
	changed = False
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			changed = True
			s = s[:i] + s[i + 2:]
			break
if s == '':
	print('Empty String')
else:
	print(s)


s = input()

def reduce(s, p):
	if p in s:
		ind = s.index(p)
		s = s.replace(p, '')
	return s
s_copy = s
for i in range(len(s_copy)):
	s = reduce(s, s_copy[i] * 2)
if len(s) == 0:
	print('Empty String')
else:
	print(s)


import copy
s = input().strip()
s_set = set(list(s))
done = False
new_s = copy.deepcopy(s)
last = ''
while not done:
	for c in s_set:
		new_s = new_s.replace(c + c, '')
	if new_s == last:
		done = True
	last = copy.deepcopy(new_s)
print('Empty String' if len(new_s) == 0 else new_s)


import sys

def find(strint):
	for i in range(len(string) - 1):
		if string[i] == string[i + 1]:
			return i
	return -1
string = sys.stdin.readline().rstrip()
idx = find(string)
while idx != -1:
	string = string[:idx] + string[idx + 2:]
	idx = find(string)
if len(string) == 0:
	string = 'Empty String'
print(string)


s = input().strip()
i = 0
while True:
	if i >= len(s) - 1:
		break
	if s[i] == s[i + 1]:
		s = s[:i] + s[i + 2:]
		i = 0
		continue
	i += 1
if len(s) == 0:
	print('Empty String')
else:
	print(s)


S = input()
i = 0
while i < len(S) - 1:
	if S[i] == S[i + 1]:
		if i + 2 < len(S):
			S = S[:i] + S[i + 2:]
		else:
			S = S[:i]
		i = max(0, i - 1)
	else:
		i += 1
if S:
	print(S)
else:
	print('Empty String')


astr = input().strip()
alist = list(astr)
hitflag = 1
while hitflag:
	hitflag = 0
	for k in range(len(alist) - 1):
		if alist[k] == alist[k + 1]:
			alist.pop(k + 1)
			alist.pop(k)
			hitflag = 1
			break
if len(alist) == 0:
	print('Empty String')
else:
	for a in alist:
		print(a, end='')
	print()


s = input()
while 1:
	s0 = s
	for sym in s:
		index = s.find(sym * 2)
		if index > -1:
			s = s[:index] + s[index + 2:]
	if s == s0:
		break
s = s or 'Empty String'
print(s)


from array import array
line = input()
line = list(line)

def reduce_line(line):
	changed = False
	newline = []
	i = 0
	while i < len(line):
		if i < len(line) - 1 and line[i] == line[i + 1]:
			changed = True
			i += 2
		else:
			newline.append(line[i])
			i += 1
	return (newline, changed)
while True:
	(line, changed) = reduce_line(line)
	if not changed:
		break
if line:
	print(''.join(line))
else:
	print('Empty String')


import sys
inp = list(input().strip())
new = list(inp)
i = 0
while i < len(inp) - 1:
	if inp[i] == inp[i + 1]:
		inp.pop(i + 1)
		inp.pop(i)
		i = 0
	else:
		i += 1
if len(inp) == 0:
	print('Empty String')
else:
	print(''.join(inp))


string = input()
i = 0
while i < len(string):
	if i < len(string) - 1 and string[i] == string[i + 1]:
		string = string[:i] + string[i + 2:]
		i = 0
	else:
		i += 1
if string:
	print(string)
else:
	print('Empty String')


import re

def recursor(s):
	slist = list(s)
	last = None
	for (i, c) in enumerate(slist):
		if c == last:
			return re.sub(c + last, '', s)
		else:
			last = c
	return None

def nextMove(s):
	while s != '' and recursor(s) is not None:
		s = recursor(s)
	if s == '':
		return 'Empty String'
	else:
		return s
s = str(input())
print(nextMove(s))


def reduce(s):
	reduced = []
	last = ''
	for ch in s:
		if ch != last:
			reduced.append(ch)
			last = ch
		else:
			_ = reduced.pop()
			if len(reduced) == 0:
				last = ''
			else:
				last = reduced[-1]
	if len(reduced) == 0:
		return 'Empty String'
	return ''.join(reduced)

def localtest():
	assert reduce('aaabccddd') == 'abd'
	assert reduce('baab') == 'Empty String'
	assert reduce('aa') == 'Empty String'

def hackerrank():
	ss = input()
	print(reduce(ss))
hackerrank()


S = list(input().strip())
if len(S) == 1:
	print(S[0])
else:
	i = 0
	while i <= len(S) - 1:
		if i < len(S) - 1:
			if S[i] == S[i + 1]:
				S.pop(i + 1)
				S.pop(i)
				continue
		if S[i] == S[i - 1] and i > 0:
			S.pop(i)
			S.pop(i - 1)
			i -= 1
		else:
			i += 1
	if S:
		print(''.join(S))
	else:
		print('Empty String')


def reduce(string):
	if len(string) == 0:
		return 'Empty String'
	strlen = len(string)
	for i in range(0, strlen - 1):
		if string[i] == string[i + 1]:
			newstr = string[:i] + string[i + 2:]
			return reduce(newstr)
	return string
string = input()
print(reduce(string))


s = input()

def remove_pairs(string):
	new_string = ''
	length = len(string)
	i = 0
	while i < length:
		try:
			if string[i] != string[i + 1]:
				new_string += string[i]
				i += 1
			else:
				i += 2
		except IndexError:
			new_string += string[i]
			break
	if len(new_string) == length:
		return new_string
	else:
		return remove_pairs(new_string)
print(remove_pairs(s) or 'Empty String')


S = input()
c = True
T = S
while c:
	c = False
	for i in range(len(T) - 1):
		if T[i] == T[i + 1]:
			T = T[:i] + T[i + 2:]
			c = True
			break
if len(T) == 0:
	print('Empty String')
else:
	print(T)


str = input()
reduced = True
while len(str) > 0 and reduced == True:
	reduced = False
	i = 0
	while i < len(str) - 1:
		if str[i] == str[i + 1]:
			if i + 2 <= len(str):
				newstr = str[:i] + str[i + 2:]
				str = newstr
				i = i + 2
			else:
				newstr = str[:i]
				str = newstr
				break
			reduced = True
		i += 1
if len(str) == 0:
	print('Empty String')
else:
	print(str)


import re
x = input()
while True:
	y = re.sub('(\\w)\\1', '', x)
	if x == y:
		break
	x = y
if x:
	print(x)
else:
	print('Empty String')


in_str = input().strip()
i = 0
while i < len(in_str):
	if i + 1 < len(in_str) and in_str[i] == in_str[i + 1]:
		in_str = in_str[0:i] + (in_str[i + 2:] if i + 2 < len(in_str) else '')
		i = 0
	else:
		i += 1
if in_str == '':
	in_str = 'Empty String'
print(in_str)


import re
S = input()
while True:
	(S, n) = re.subn('([a-z])\\1', '', S)
	if not n:
		break
print(S if S else 'Empty String')


def solve(s):
	i = 0
	while i + 1 < len(s):
		if s[i] == s[i + 1]:
			s = s[0:i] + s[i + 2:]
			i = max(i - 1, 0)
		else:
			i += 1
	return s
s = input().strip()
soln = solve(s)
if soln == '':
	print('Empty String')
else:
	print(soln)


def getSuperReducedString(s):
	l = list(s)
	while 1:
		count = 0
		i = 1
		while i < len(l):
			if l[i] == l[i - 1] and l[i] != '':
				del l[i]
				del l[i - 1]
				count += 1
			i += 1
		if count == 0:
			break
	return ''.join(l)
s = input().strip()
s = getSuperReducedString(s)
if s:
	print(s)
else:
	print('Empty String')


flag = 0
test = input()
while flag == 0:
	temporal = [x for x in test]
	leng = len(test)
	if len(test) == 0:
		flag = 1
	for i in range(leng - 1):
		if test[i] == test[i + 1]:
			test = test[0:i] + test[i + 2:len(temporal)]
			flag = 0
			break
		elif test[i] != test[i + 1]:
			flag = 1
if len(test) == 0:
	print('Empty String')
else:
	print(test)


s = input().strip()
while True:
	can_reduce = False
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			s = s[:i] + s[i + 2:]
			can_reduce = True
			break
	if not can_reduce:
		break
if s == '':
	print('Empty String')
else:
	print(s)


S = input()

def reducer(x):
	Z = ''
	l = len(x)
	offset = 0
	for i in range(l):
		try:
			current = S[i + offset]
			try:
				next = S[i + offset + 1]
				if current == next:
					offset += 1
				else:
					Z += current
			except:
				Z += current
		except:
			None
	return Z
while 1:
	lS = len(S)
	S = reducer(S)
	if lS == len(S):
		break
if len(S) == 0:
	print('Empty String')
else:
	print(S)


word = input()
oldword = ''
while oldword != word:
	oldword = word
	for i in range(1, len(word)):
		while i < len(word) and word[i - 1] == word[i]:
			word = word[:i - 1] + word[i + 1:]
		if i == len(word) - 1:
			break
if word == '':
	word = 'Empty String'
print(word)


s = input()

def shortest_string(s):
	if not s:
		print('Empty String')
	chars = list(s)
	result = []
	i = 0
	while i < len(chars) - 1:
		if chars[i] == chars[i + 1]:
			chars = chars[:i] + chars[i + 2:]
			i = 0
		else:
			i += 1
	string = ''.join(chars)
	if not string:
		print('Empty String')
	else:
		print(string)
shortest_string(s)


x = input()
c = len(x)
z = ''
i = 0
lst = []
for z in range(97, 123):
	lst.append(chr(z) + chr(z))
for i in range(len(x)):
	for a in lst:
		x = x.replace(a, '')
if len(x) == 0:
	print('Empty String')
else:
	print(x)


def solve(s):
	if len(s) == 0:
		return 'Empty String'
	a = -1
	for i in range(1, len(s)):
		if s[i - 1] == s[i]:
			a = i - 1
			break
	if a == -1 and len(s) > 0:
		return ''.join([x for x in s])
	elif a == -1 and len(s) == 0:
		return 'Empty String'
	del s[a]
	del s[a]
	return solve(s)
s = input().strip()
print(solve(list(s)))


s = input()
change = True
while change == True:
	change = False
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			s = s[:i] + s[i + 2:]
			change = True
			break
if len(s) > 0:
	print(s)
else:
	print('Empty String')


s = input()
while True:
	char_groups = []
	char_group = []
	for (i, c) in enumerate(s):
		char_group.append(c)
		try:
			assert s[i + 1] == c
		except (AssertionError, IndexError):
			char_groups.append(''.join(char_group))
			char_group = []
	if not [cg for cg in char_groups if len(cg) % 2 == 0]:
		break
	s = ''.join([cg[0] for cg in char_groups if len(cg) % 2 != 0])
print(s if s else 'Empty String')


import re
s = input().strip()
rx = re.compile('(.)\\1{1}')
while True:
	new_s = re.sub(rx, '', s)
	if len(new_s) == len(s):
		print(new_s)
		break
	elif len(new_s) == 0:
		print('Empty String')
		break
	else:
		s = new_s


def done(st):
	flag = True
	for i in range(1, len(st)):
		if st[i] == st[i - 1]:
			flag = False
			break
	if flag:
		if st != '':
			return [True, st]
		else:
			return [True, 'Empty String']
	else:
		return [False, None]

def fun(st):
	temp = st
	while True:
		if done(temp)[0] == True:
			print(done(temp)[1])
			break
		temp_2 = ''
		c = 1
		for i in range(1, len(temp)):
			if temp[i] == temp[i - 1]:
				c += 1
			else:
				if c % 2 == 1:
					temp_2 += temp[i - 1]
				c = 1
		if temp[len(temp) - 1] == temp[len(temp) - 2]:
			if c % 2 == 1:
				temp_2 += temp[len(temp) - 1]
		else:
			temp_2 += temp[len(temp) - 1]
		temp = temp_2
st = input()
fun(st)


text = input()
i = len(text) - 1
while i > 0:
	if text[i - 1] == text[i]:
		text = text[:i - 1] + text[i + 1:len(text)]
		i = len(text) - 1
		continue
	i -= 1
print('Empty String' if len(text) == 0 else text)


s = input().strip()
s = [i for i in s]
l = len(s)
for i in range(0, l):
	for j in range(0, len(s) - 1):
		try:
			cur = s[j]
			nxt = s[j + 1]
			if cur == nxt:
				s.pop(j)
				s.pop(j)
		except IndexError:
			pass
if len(s) == 0:
	print('Empty String')
else:
	print(''.join(s))


s = input()

def recsolver(s):
	if len(s) == 0:
		return 'Empty String'
	elif len(s) == 1:
		return s
	else:
		res = s
		i = 0
		while i < len(s) - 1:
			if s[i] == s[i + 1]:
				res = s[:i] + s[i + 2:]
				break
			i += 1
		if len(res) == len(s):
			return s
		else:
			return recsolver(res)
print(recsolver(s))


def solve(cad):
	r = ''
	tams = len(cad)
	repeated = 1
	for i in range(1, tams):
		if cad[i] != cad[i - 1]:
			if repeated % 2 == 1:
				r += cad[i - 1]
			repeated = 1
		else:
			repeated += 1
	if repeated % 2 == 1 and tams > 0:
		r += cad[tams - 1]
	return r
s = input()
while True:
	tams = len(s)
	s = solve(s)
	if len(s) == 0:
		print('Empty String')
		break
	elif tams == len(s):
		print(s)
		break


def simplify(s):
	t = list(s)
	t.append(None)
	while True:
		indices = None
		i = 0
		while i < len(t) - 1:
			if t[i] == t[i + 1]:
				indices = (i, i + 1)
				break
			else:
				i += 1
		if indices is None:
			return t
			break
		else:
			t.pop(i + 1)
			t.pop(i)
s = simplify(input())[:-1]
if s == []:
	print('Empty String')
else:
	print(''.join(s))


s = input()
while True:
	if s == '':
		break
	l = len(s)
	r = ''
	flag = True
	i = 0
	while i < l:
		if i < l - 1 and s[i] == s[i + 1]:
			i += 1
			flag = False
		else:
			r += s[i]
		i += 1
	s = r
	if flag:
		break
if s == '':
	print('Empty String')
else:
	print(s)


s = input()
ss = ''
list1 = list(s)
for i in range(len(list1)):
	count = -1
	for j in list1:
		count = count + 1
		if count != len(list1) - 1:
			if j == list1[count + 1]:
				list1.pop(count + 1)
				list1.pop(count)
		if len(list1) == 0:
			print('Empty String')
			exit()
for i in list1:
	print(i, end='')


import sys
S = input()
SS = []
for i in range(len(S)):
	if len(SS) == 0 or S[i] != SS[-1]:
		SS.append(S[i])
	else:
		SS = SS[:-1]
print(''.join(SS) if len(SS) > 0 else 'Empty String')


S = list(input().strip())
deletes = [0 for c in S]
while True:
	found1 = False
	for i in range(0, len(S) - 1):
		if deletes[i] == -1:
			continue
		j = i + 1
		found2 = False
		while j < len(S):
			if deletes[j] != -1:
				found2 = True
				break
			j += 1
			if j == len(S):
				break
		if not found2:
			break
		if S[i] == S[j]:
			(deletes[i], deletes[j]) = (-1, -1)
			found1 = True
	if not found1:
		break
ans = ''
for i in range(0, len(deletes)):
	if deletes[i] == 0:
		ans += S[i]
if ans == '':
	print('Empty String')
else:
	print(ans)


import sys
s = input()
while True:
	prev_c = None
	new_s = ''
	for i in range(len(s)):
		if prev_c == s[i]:
			new_s = new_s[:-1]
			new_s += s[i + 1:]
			break
		else:
			prev_c = s[i]
			new_s += prev_c
	print(s, new_s, file=sys.stderr)
	if s == new_s:
		break
	else:
		s = new_s
if len(s) == 0:
	print('Empty String')
else:
	print(s)


import sys

def resolve(line):
	found = True
	while found:
		lastch = None
		points = []
		lastindex = -200
		found = False
		for (idx, ch) in enumerate(line):
			if lastch == ch:
				found = True
				line = line[:idx - 1] + line[idx + 1:]
				break
			lastch = ch
	return line

def main():
	r = sys.stdin.readline
	line = r().strip()
	ret = resolve(line)
	minlen = 2000
	retstr = None
	if len(ret) == 0:
		print('Empty String')
	else:
		print(ret)
main()


word = input()
while True:
	ch_list = []
	counter = iter(range(len(word)))
	for i in counter:
		if i + 1 < len(word) and word[i] == word[i + 1]:
			next(counter, None)
			pass
		else:
			ch_list.append(word[i])
	new_word = ''.join(ch_list)
	if len(new_word) == len(word):
		break
	word = new_word
if len(ch_list) == 0:
	print('Empty String')
else:
	print(''.join(ch_list))


from lib2to3.fixer_util import String
string = list(input().strip())
canReduce = True
while canReduce:
	canReduce = False
	lastChar = None
	for i in range(0, len(string)):
		if string[i] == lastChar:
			del string[i - 1]
			del string[i - 1]
			canReduce = True
			break
		lastChar = string[i]
if len(string) == 0:
	print('Empty String')
else:
	for char in string:
		print(char, end='')


string = input().strip()
control = True
while control:
	for i in range(len(string) - 1):
		if string[i] == string[i + 1]:
			string = string[:i] + string[i + 2:]
			if len(string) == 0:
				control = False
				print('Empty String')
			break
		if i == len(string) - 2:
			control = False
			print(string)


def reduce(string):
	for i in range(len(string)):
		if i < len(string) - 1:
			if string[i] == string[i + 1]:
				if i == 0:
					reduce(string[2:])
					break
				else:
					reduce(string[:i] + string[i + 2:])
					break
	else:
		print(string if string else 'Empty String')
s = input().strip()
reduce(s)


def reduce(A, i):
	A = A[:i] + A[i + 2:]
	return A
A = input().strip()
n = len(A)
i = 0
while i < n - 1:
	if A[i] == A[i + 1]:
		A = reduce(A, i)
		i = i - 2
		n = len(A)
		if i < 0:
			i = -1
	i += 1
if A != '':
	print(A)
else:
	print('Empty String')


s = input()
t = ''
change = True
while change:
	change = False
	i = 1
	while i < len(s):
		if s[i] == s[i - 1]:
			change = True
			s = s.replace(s[i] * 2, '')
			break
		else:
			i += 1
if s == '':
	print('Empty String')
else:
	print(s)


s = input()
s = list(s)
if not s:
	print('Empty String')
else:
	changed = True
	while changed:
		changed = False
		for i in range(1, len(s)):
			if s[i] == s[i - 1]:
				s[i] = ' '
				s[i - 1] = ' '
				changed = True
		if changed:
			s = [i for i in s if i != ' ']
if s:
	print(''.join(s))
else:
	print('Empty String')


S = input()

def fix(S):
	cat = True
	while cat:
		cat = False
		for i in range(len(S) - 1):
			a = S[i]
			b = S[i + 1]
			if a == b:
				S = S[:i] + S[i + 2:]
				cat = True
				break
	if S == '':
		S = 'Empty String'
	return S
print(fix(S))


from sys import stdin

def SuperReducedString(S: str) -> str:
	l = len(S)
	reduceable = True
	c = 0
	while reduceable:
		c += 1
		reduceable = False
		evens = [S[i:i + 2] for i in range(0, len(S), 2)]
		S = ''
		for e in evens:
			if len(e) == 2:
				(x, y) = e
				if x == y:
					reduceable = True
				else:
					S += e
			else:
				S += e
		if not S:
			return 'Empty String'
		odds = [S[0]] + [S[i:i + 2] for i in range(1, len(S), 2)]
		S = ''
		for o in odds:
			if len(o) == 2:
				(x, y) = o
				if x == y:
					reduceable = True
				else:
					S += o
			else:
				S += o
		if not S:
			return 'Empty String'
	return S
INPUT = stdin.read().strip()
OUTPUT = SuperReducedString(INPUT)
print(OUTPUT)


s = input()
st = []
c = 0
cur = s[0]
for i in s:
	if i == cur:
		c += 1
	else:
		if c % 2 != 0:
			if st:
				if st[-1] == cur:
					st.pop(-1)
				else:
					st.append(cur)
			else:
				st.append(cur)
		cur = i
		c = 1
if c % 2 != 0:
	if st:
		if st[-1] == cur:
			st.pop(-1)
		else:
			st.append(cur)
	else:
		st.append(cur)
s = ''.join(st)
if not s:
	s = 'Empty String'
print(s)


S = list(input().strip())
i = 1
j = 1
while i < len(S):
	S[j] = S[i]
	i += 1
	j += 1
	if j >= 2 and S[j - 1] == S[j - 2]:
		j -= 2
if j == 0:
	print('Empty String')
else:
	print(''.join(S[0:j]))


def try_reduce(val):
	prev_i = 0
	for i in range(1, len(val)):
		if val[i] == None:
			continue
		if val[prev_i] == None:
			prev_i = i
			continue
		if val[prev_i] == val[i]:
			val[prev_i] = None
			val[i] = None
			return True
		prev_i = i
	return False
val = list(input())
while try_reduce(val):
	pass
answer = ''.join(filter(lambda x: x is not None, val))
print(answer if answer != '' else 'Empty String')


def reduce_str(word_list):
	if len(word_list) == 0:
		return 'Empty String'
	for i in range(len(word_list) - 1):
		if word_list[i] == word_list[i + 1]:
			word_list[i:i + 2] = []
			return reduce_str(word_list)
	return word_list
my_list = list(input())
print(''.join(reduce_str(my_list)))


str = input().strip()
x = 0
while x < len(str):
	if x + 1 < len(str):
		if str[x] == str[x + 1]:
			if x > 0:
				str = str[0:x] + str[x + 2:]
			else:
				str = str[x + 2:]
			x = -1
	else:
		break
	x += 1
if len(str) > 0:
	print(str)
else:
	print('Empty String')


import sys
import string
ref_string = input().strip()
while 1 < 2:
	if len(ref_string) != 0:
		for e in range(len(ref_string) - 1):
			if ref_string[e] == ref_string[e + 1]:
				p = 22
				break
			else:
				p = 13
	else:
		p = 13
	if p == 13:
		break
	ref_string = str.replace(ref_string, ref_string[e:e + 2], '')
if ref_string != '':
	print(ref_string)
else:
	print('Empty String')


def r(s):
	if len(s) == 1:
		return s
	i = 0
	while s and i < len(s) - 2:
		while i < len(s) - 2 and s[i] == s[i + 1]:
			s = s[:i] + s[i + 2:]
		i += 1
	while len(s) > 1 and s[-2] == s[-1]:
		s = s[:-2]
	if s:
		return s
	return 'Empty String'
s = input()
work_done = True
while work_done:
	work_done = False
	orig_len = len(s)
	s = r(s)
	if len(s) == orig_len:
		print(s)
	else:
		work_done = True


string = list(input())
i = 0
while i < len(string) - 1:
	if string[i] == string[i + 1]:
		string.pop(i + 1)
		string.pop(i)
		if i > 0:
			i -= 1
	else:
		i += 1
if len(string) == 0:
	print('Empty String')
else:
	print(''.join(string))


def reduce(s):
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			if i < len(s) - 2:
				s = s[:i] + s[i + 2:]
			else:
				s = s[:i]
			break
	return s
s = input().strip()
while True:
	tmp = s
	s = reduce(s)
	if tmp == s:
		break
if len(s) == 0:
	print('Empty String')
else:
	print(s)


shil = list(input())

def remover(shil):
	l = len(shil)
	for i in range(len(shil) - 1):
		if shil[i] == shil[i + 1]:
			shil.pop(i)
			shil.pop(i)
			break
	if len(shil) == 0:
		return 'Empty String'
	if l == len(shil):
		return ''.join(shil)
	else:
		return remover(shil)
print(remover(shil))


s = input()
stack = []
for c in s:
	if len(stack) > 0 and stack[-1] == c:
		stack.pop()
	else:
		stack.append(c)
if len(stack) == 0:
	print('Empty String')
else:
	print(''.join(stack))


s = input()
i = 0
while i < len(s) - 1 and s:
	if s[i] == s[i + 1]:
		j = i + 2
		s = s[0:i] + s[j:]
		i = 0
	else:
		i += 1
if s:
	print(s)
else:
	print('Empty String')


import sys
s = input()

def solve(s):
	rval = []
	(i, l) = (0, len(s))
	print(i, s, file=sys.stderr)
	while i < l - 1:
		if s[i] == s[i + 1]:
			s = s[:i] + s[i + 2:]
			l -= 2
			if i > 0:
				i -= 1
		else:
			i += 1
		print(i, s, file=sys.stderr)
	return s
s = solve(s)
if s:
	print(s)
else:
	print('Empty String')


def has_adj(s):
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			return i
	return -1

def remove_adj(s):
	i = has_adj(s)
	if i == -1:
		return s
	else:
		del s[i]
		del s[i]
		return remove_adj(s)
s = list(input())
res = remove_adj(s)
if res:
	print(''.join(res))
else:
	print('Empty String')


def read_string():
	return str(input().strip())

def reduce(ss):
	red = ''
	if len(ss) > 0:
		curr_char = ss[0]
		curr_count = 1
		ss += '£'
		for i in range(1, len(ss)):
			if ss[i] == curr_char:
				curr_count += 1
			else:
				if curr_count % 2 == 1:
					red += curr_char
				curr_char = ss[i]
				curr_count = 1
	return red
S = read_string()
reduced1 = reduce(S)
reduced2 = reduce(reduced1)
while len(reduced2) < len(reduced1):
	(reduced1, reduced2) = (reduced2, reduce(reduced2))
reduced = reduced2
if len(reduced) == 0:
	reduced = 'Empty String'
print(reduced)


import re
word = input()
while re.search('(.)\\1', word):
	word = re.sub('(.)\\1', '', word)
print(word if word else 'Empty String')


s = input()
i = 0
while i <= len(s) - 2:
	if s[i] == s[i + 1]:
		s = s[:i] + s[i + 2:]
		if i > 0:
			i -= 1
	else:
		i += 1
if s == '':
	print('Empty String')
else:
	print(s)


s = input().strip()
c = 0
patterns = [chr(x) * 2 for x in range(97, 123)]
while c < 26:
	for p in patterns:
		c += 1
		(start, part, end) = s.partition(p)
		if part is not '':
			s = start + end
			c = 0
			break
	if c == 26:
		break
print(s if s is not '' else 'Empty String')


import re
(word, prevword) = (input(), '')
while word != prevword:
	(prevword, word) = (word, re.sub('(.)\\1', '', word))
print(word if word else 'Empty String')


import re
str = input()
test = str
while re.search('([a-zA-Z])(\\1)', test):
	for i in range(0, len(test)):
		if i + 1 < len(test) and test[i].__eq__(test[i + 1]):
			test = test.replace(test[i] + test[i + 1], '')
if test.__eq__(''):
	print('Empty String')
else:
	print(test)


import re
(word, prevword) = (input(), '')
while word != prevword:
	(prevword, word) = (word, re.sub('(.)\\1', '', word))
print(word if word else 'Empty String')


s = list(input())
i = 0
while i < len(s) - 1:
	if s[i] == s[i + 1]:
		del s[i]
		del s[i]
		i = max(i - 2, -1)
	i += 1
print('Empty String' if not s else ''.join(s))


l = list(input().strip())
i = 0
while i < len(l) - 1:
	if l[i] == l[i + 1]:
		l.pop(i)
		l.pop(i)
		i = 0
	else:
		i = i + 1
if not l:
	print('Empty String')
else:
	print(''.join(l))


s = input()
while True:
	ans = True
	i = 0
	while i < len(s) - 2:
		if s[i] == s[i + 1]:
			ans = False
			s = s[:i] + s[i + 2:]
			continue
		i += 1
	if ans:
		break
if len(s) == 2 and s[0] == s[1]:
	print('Empty String')
elif s[-1] == s[-2]:
	print(s[:-2])
else:
	print(s)


a = list(input())
while True:
	again = False
	for i in range(len(a) - 1):
		if a[i] == a[i + 1]:
			a.pop(i)
			a.pop(i)
			again = True
			break
	if not again:
		break
res = ''.join(a)
if not a:
	print('Empty String')
else:
	print(res)


s = input().strip()
done = False
while not done:
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			s = s[0:i] + s[i + 2:len(s)]
			break
	else:
		break
print(s if s else 'Empty String')


def red(x):
	l1 = len(x)
	if l1 == 0:
		return (False, '')
	last = x[0]
	count = 1
	out = ''
	for i in range(1, len(x)):
		c = x[i]
		if c == last:
			count += 1
		else:
			if count % 2 == 1:
				out += last
			last = c
			count = 1
	if count % 2 == 1:
		out += last
	return (l1 != len(out), out)
x = input()
if len(x) == 0:
	print('Empty String')
else:
	out = x
	while True:
		(reduced, out) = red(out)
		if not reduced:
			break
	print(out) if len(out) > 0 else print('Empty String')


s = input()
if len(s) == 1:
	print(s)
	exit()

def rs(s):
	x = 0
	y = 1
	c = s[0]
	r = ''
	while y < len(s):
		if s[x] == s[y]:
			x = y + 1
			y = x + 1
		else:
			r += s[x]
			x += 1
			y += 1
	if x == len(s) - 1:
		r += s[x]
	return r
while True:
	r = rs(s)
	if r == s:
		print(r)
		exit()
	if len(r) == 0:
		print('Empty String')
		exit()
	s = r