qyliang/CodeNanoFix huggingface dataset:
Buggy code:
s = input()
s+=" "
n=len(s)
ans=0
c=0
m=0
a=s[0]
for i in range(n):
        if s[i]!=a:
                if c%3==0:
                        ans+=(c//3)*2;
                else:
                        ans+=1+(c//3)*2
                        if m==2 and c%3==2:
                                ans+=1
                                m=0
                        elif c%3!=0:
                                m=c%3
                        c=1
                else:
			c+=1
		a=s[i]
	print(ans)

Fixed code:
def main():
	s = input()
	s+=" "
	n=len(s)

	ans=0
	c=0
	m=0
	a=s[0]
	for i in range(n):
		if s[i]!=a:
			if c%3==0:
				ans+=(c//3)*2;
			else:
				ans+=1+(c//3)*2
			if m==2 and c%3==2:
				ans+=1
				m=0
			elif c%3!=0:
				m=c%3
			c=1
		else:
			c+=1
		a=s[i]
	print(ans)
main()
Buggy code:
S = input()
ans = 0
p = ''
i = 0

while i < len(S):
  ans+=1
  if p==S[i]:
    i+=2
    p=''
  else:
    i+=1
    p=S[i]
    
print(ans)


Fixed code:
S = input()
ans = 0
p = ''
i = 0

while i < len(S):
  ans+=1
  if p==S[i]:
    if i==len(S)-1:
      ans-=1
    i+=2
    p=''
  else:
    p=S[i]
    i+=1
print(ans)
Buggy code:
s = [i for i in input()]
 
result = 1
i = 0
while i < len(s)-1:
  if s[i] == s[i+1]:
    i = i + 2
      if i > len(s):
        result = result - 1
  else:
    i = i + 1
  result = result + 1
  
print(result)

Fixed code:
s = [i for i in input()]
result = 1
i = 0

while i < len(s)-1:
  if s[i] == s[i+1]:
    i += 3
    result += 2
  else:
    i += 1
    result += 1
    
if i == len(s):
  result -= 1
elif i > len(s):
  result -= 2
  
print(result)
Buggy code:
s = [i for i in input()]
count = 1
s0 = s[0]
flag = 0
for i in range(1, len(s)):
    if flag==1:
        flag = 0
        continue
    if s0==s[i]:
        s0 = s[i] + s[i+1]
        flag = 1
    else:
        s0 = s[i]
    count += 1
    print(s0)
print(count)

Fixed code:
s = [i for i in input()]
count = 1
s0 = s[0]
flag = 0
for i in range(1, len(s)):
    try:
        if flag==1:
            flag = 0
            continue
        if s0==s[i]:
            s0 = s[i] + s[i+1]
            flag = 1
        else:
            s0 = s[i]
        count += 1
    except:
        continue
print(count)
Buggy code:
S = input() + 'A'
ans, prev, next = 1, [S[0]], []
print(prev)
for i in range(1, len(S)):
    if len(next) == 0 or prev == next:
        next.append(S[i])
    else:
        print(next)
        ans, prev, next = ans + 1, next, [S[i]]

print(ans)


Fixed code:
S = input() + 'A'
ans, prev, next = 1, [S[0]], []
for i in range(1, len(S)):
    if len(next) == 0 or prev == next:
        next.append(S[i])
    else:
        ans, prev, next = ans + 1, next, [S[i]]

print(ans)
Buggy code:
S = input()

l = [0] * (len(S) + 1)
l[1] = 1
if S[0] == S[1]:
    l[2] = 1
else:
    l[2] = 2

for i in range(3, len(S)+1):
    if S[i-1] == S[i-2]:
        l[i] = l[i-1] + 1
    else:
        l[i] = l[i-3] + 2

print(l[-1])

Fixed code:
S = input()

l = [0] * (len(S) + 1)
l[1] = 1
if S[0] == S[1]:
    l[2] = 1
else:
    l[2] = 2

for i in range(3, len(S)+1):
    if S[i-1] != S[i-2]:
        l[i] = l[i-1] + 1
    else:
        l[i] = l[i-3] + 2

print(l[-1])
Buggy code:
s=input()
l=len(s)
c=0
x=0
while x<l-1:
  if s[x]==s[x+1]:
    c+=2
    x+=3
  else:
    c+=1
    x+=1
print(c)

Fixed code:
s=input()
l=len(s)
c=0
x=0
while x<l-1:
  if s[x]==s[x+1]:
    if x==l-2:
      c+=1
      x+=2
    else:
      c+=2
      x+=3
  else:
    if x==l-2:
      c+=2
      x+=2
    else:
      c+=1
      x+=1
if l==1:
  c=1
if x==l-1:
  c+=1
print(c)
Buggy code:
import sys

#+++++
		
def main():
	s = input()
	if len(s) == 1:
		return 1
	
	ls=list(s)
	cc=ls[0]
	count=1
	nl=[]
	for c in ls[1:]:
		if c == cc:
			count+=1
		else:
			nl.append(count)
			cc=c
			count=1
	nl.append(count)
	
	nnl=[]
	ret=0
	for i in nl:
		b = i % 3
		if b != 0:
			ret += 1
			
		k = i // 3
		ret += k* 2
		nnl.append(b)

	cc=1
	for i in nnl:
		#print(i,nnl,ret)
		if cc == 2 and i == 2:
			cc = 0
			ret +=1
		elif cc != 2 and i == 2:
			cc=2
		elif cc == 2 and i == 1:
			pass
		else:
			cc=0
	
	print(ret)

	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Fixed code:
import sys

#+++++
		
def main():
	s = input()
	if len(s) == 1:
		return 1
	
	ls=list(s)
	cc=ls[0]
	count=1
	nl=[]
	for c in ls[1:]:
		if c == cc:
			count+=1
		else:
			nl.append(count)
			cc=c
			count=1
	nl.append(count)
	
	nnl=[]
	ret=0
	for i in nl:
		b = i % 3
		if b != 0:
			ret += 1
			
		k = i // 3
		ret += k* 2
		nnl.append(b)

	cc=1
	for i in nnl:
		#print(i,nnl,ret)
		if cc == 2 and i == 2:
			cc = 0
			ret +=1
		elif cc != 2 and i == 2:
			cc=2
		elif cc == 2 and i == 0:
			pass
		else:
			cc=0
	
	print(ret)

	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)
Buggy code:
s = input()
num = len(s)
ans = 0
ss = s

pos = 0

while True:
  c = s[pos]
  count = 1
  for i in range(num - pos):
    if s[pos + i] == c:
      count += 1
    else:
      ans += (count//3)*2  
      if i < num:
        if count % 3 == 1:
          ans += 1
        elif count % 3 == 2:
          ans += 2
          pos += 1
      break
  pos += count
  
  if pos >= num:
    ans += (count // 3) * 2 
    if count % 3 != 0:
      ans += 1

    break


print(ans)


Fixed code:
s = input()
num = len(s)
ans = 0
pos = 0
 
while True:
  c = s[pos]
  count = 0
  for i in range(num - pos):
    if s[pos + i] == c:
      count += 1
    else:
      ans += (count//3)*2  
      if i < num:
        if count % 3 == 1:
          ans += 1
        elif count % 3 == 2:
          ans += 2
          pos += 1
          pos += count
          count = 0
          
      break
  pos += count
  
  if pos >= num:
    ans += (count // 3) * 2 
    if count % 3 != 0:
      ans += 1
 
    break
 
 
print(ans)
Buggy code:
s=input()+'!'
l=len(s)
ans=1
pos=1
tmp=s[0]
flag=0
while pos<l:
  if s[pos]!=tmp:
    tmp=s[pos]
    ans+=1
    pos+=1
  else:
    if s[pos]==tmp:
      tmp=s[pos:pos+2]
      ans+=1
      pos+=2
  print(ans,pos,tmp)
ans-=1
print(ans)

Fixed code:
s=input()+'!'
l=len(s)
ans=1
pos=1
tmp=s[0]
flag=0
while pos<l:
  if s[pos]!=tmp:
    tmp=s[pos]
    ans+=1
    pos+=1
  else:
    if s[pos]==tmp:
      tmp=s[pos:pos+2]
      ans+=1
      pos+=2
ans-=1
print(ans)
Buggy code:
s=input()
 
tmp=""
last=""
cnt=1
for s_ in s:
  tmp+=s_
  if tmp != last:
    last=tmp
    tmp=''
    cnt+=1
print(cnt)

Fixed code:
s=input()
 
tmp=""
last=""
cnt=0
for s_ in s:
  tmp+=s_
  if tmp != last:
    last=tmp
    tmp=''
    cnt+=1
print(cnt)
Buggy code:
S = input()
ans, prev, cur = 0, "", ""
for s in S:
    cur += 
    if cur != prev:
        ans += 1
        prev, cur = cur, ""
print(ans)

Fixed code:
S = input()

ans = 0
prev, cur = "", ""
for s in S:
    cur += s
    if cur != prev:
        prev, cur = cur, ""
        ans += 1

print(ans)
Buggy code:
string = input()
temp = ""
count = 0
for s in string:
  if temp == "":
    temp = s
  elif temp != s:
    count += 1
    temp = s
  else:
    temp += s
  
print(count)

Fixed code:
string = input()
temp = ""
last = ""
count = 0
for s in string:
    if temp=="":
        temp=s
    elif temp==last:
        temp+=s
    else:
        last=temp
        temp=s
        count+=1
        
if temp != "" and temp != last:
    count += 1

print(count)
Buggy code:
r = 0
p = None
for c in input():
    if p:
        p = None
        r += 1
    elif c == p:
        p = c
    else:
        r += 1
        p = c
print(r)


Fixed code:
r = 0
p = None
for c in input():
    if p == 1:
        p = None
        r += 1
    elif c == p:
        p = 1
    else:
        r += 1
        p = c
print(r)
Buggy code:
s = str(input())

j = 0
count = len(s)
s = [_ for _ in s]
for i in range(0, len(s)-1):
    if j+2 <= len(s)-1:
        if s[j] == s[j+1]:
            j = j+3
            count -= 1
        else:
            continue
    
print(count)

Fixed code:
s = str(input())

j = 0
count = len(s)

s = [_ for _ in s]
for i in range(0, len(s)-1):
    if j+1 <= len(s)-1:
        if s[j] == s[j+1]:
            j = j + 3
            count -= 1
        else:
            j = j + 1
            continue

print(count)
Buggy code:
s = input()
it=0
con = 1
while it+1 < len(s):
	if s[it] == s[it+1]:
		if it + 2 == len(s):
			it += 2
			con += 0
		elif it + 3 == len(s):
			it += 3
			con += 1
        else:
			it += 3
			con += 2
	else:
		it += 1
		con += 1
print(con)

Fixed code:
s = input()
it=0
con = 1
while it+1 < len(s):
	if s[it] == s[it+1]:
		if it + 2 == len(s):
			it += 2
			con += 0
		elif it + 3 == len(s):
			it += 3
			con += 1
		else:
			it += 3
			con += 2
	else:
		it += 1
		con += 1
print(con)
Buggy code:
s=input()

count=1
k=0

for i in range(len(s)-1):
    if s[i+k]==s[i+k+1]:
        k+=2
        count+=2
        if i+k>=len(s)-2:
            print(count)
            exit()
    else:
        count+=1
        if i+k>=len(s)-2:
            print(count)
            exit()

Fixed code:
s=input()
s=str(0)+s
count=0
k=0

for i in range(1,len(s)):
    if s[i+k-1]==s[i+k]:
        count+=2
        k+=2
        if i+k==len(s)+1:
            print(count-2)
            exit()
        if i+k==len(s):
            print(count-1)
            exit()
        if i+k==len(s)-1:
            print(count)
            exit()
    else:
        count+=1
        if i+k>=len(s)-1:
            print(count)
            exit()
Buggy code:
S=input()

i=1
K=1
lastword=[]
lastword.append(S[0])
while i<= (len(S)-1):
  if i==len(S)-1:
    if len(lastword[-1])==1 and S[i]!=S[i-1] or len(lastword[-1])==2:
      K+=1
      break
    elif len(lastword[-1])==1 and S[i]==S[i-1]:
      if lastword[-3]==lastword[-1]:
        break
      else:
        K+=1
        break
  
  if len(lastword[-1])==1:
    if S[i]!=S[i-1]:
      lastword.append(S[i])
      i+=1
      K+=1
    else:
      lastword.append(S[i:i+2])  
      i+=2
      K+=1
  else:     # len(lastword)==2:
    lastword.append(S[i])
    i+=1
    K+=1
  print(i,K,lastword)

print(K)

Fixed code:
S=input()

i=1
K=1
lastword=[]
lastword.append(S[0])
while i<= (len(S)-1):
  if i==len(S)-1:
    if len(lastword[-1])==1 and S[i]!=S[i-1] or len(lastword[-1])==2:
      K+=1
      break
    elif len(lastword[-1])==1 and S[i]==S[i-1]:
      if lastword[-3]==lastword[-1] or lastword[-1]!=lastword[-2]:
        break
      else:
        K+=1
        break
  
  if len(lastword[-1])==1:
    if S[i]!=S[i-1]:
      lastword.append(S[i])
      i+=1
      K+=1
    else:
      lastword.append(S[i:i+2])  
      i+=2
      K+=1
  else:     # len(lastword)==2:
    lastword.append(S[i])
    i+=1
    K+=1
#  print(i,K,lastword)

print(K)
Buggy code:
s = input()

def dp(sb, c_1):
  ret = ''
  for i,c in enumerate(sb):
    ret += c
    if c_1 != ret:
      return sb[i+1:], ret
  return False, False
    
sb = s
c_1 = ''
cnt = 0
while True:
  sb, c_1 = dp(sb, c_1)
  #print(c_1)
  if sb == False: 
    cnt += 1
    break
  cnt += 1
  if len(sb) == 0:
    break
print(cnt)

Fixed code:
s = input()
 
def dp(sb, c_1):
  ret = ''
  for i,c in enumerate(sb):
    ret += c
    if c_1 != ret:
      return sb[i+1:], ret
  return False, False
    
sb = s
c_1 = ''
cnt = 0
while True:
  sb, c_1 = dp(sb, c_1)
  #print(c_1)
  if sb == False: 
    break
  cnt += 1
  if len(sb) == 0:
    break
print(cnt)
Buggy code:
while True:
    try:
        S = input()
        result = 0
        prev = None
        cur = ""
        print(S)
        for c in S:
            if prev is None:
                prev = c
                result += 1
                print(prev, cur, result)
                continue
            cur += c
            if prev == cur:
                print(prev, cur, result)
                continue
            result += 1
            print(prev, cur, result)
            prev = cur
            cur = ""
        print(result)
    except EOFError:
        break

Fixed code:
while True:
    try:
        S = input()
        result = 0
        prev = None
        cur = ""
        for c in S:
            if prev is None:
                prev = c
                result += 1
                continue
            cur += c
            if prev == cur:
                continue
            result += 1
            prev = cur
            cur = ""
        print(result)
    except EOFError:
        break
Buggy code:
S = input()
a = ""
stock = ""
data = []

for i in S:
    a = a + i
    if a != stock:
        stock = a
        data.append(a)
        a = ""
count = len(data)


if a == stock:
    i = 1
    data.append(a)
    check = 1
    c = 0
    while True:
        word = ""
        a = ""
        c = 0
        stock2 = ""
        data2 = []
        for j in range(i+1):
            word = data[-(j+1)] + word
        
        for j in reversed(word):
            c += 1
            a = j + a
            if check > c:
                continue
            if a != stock2:
                stock2 = a
                data2.insert(0,a)
                a = ""
        if len(data2) < 2:
            count = 1
            break
        if (len(S)<=i+2) and (data2[0]!=data2[1]) and (a == ""):
            count = len(data2)
            break
        elif len(S)<=i+2:
            check += 1
            continue
        if (data2[0] != data[-(i+2)]) and (a == ""):
            count = len(data) - (i+1) + len(data2)
            break
        i += 1
        
        
print(count)

Fixed code:
S = input()
a = ""
stock = ""
data = []

for i in S:
    a = a + i
    if a != stock:
        stock = a
        data.append(a)
        a = ""
count = len(data)


if a == stock:
    i = 1
    data.append(a)
    check = 1
    c = 0
    while True:
        word = ""
        a = ""
        c = 0
        stock2 = ""
        data2 = []
        for j in range(i+1):
            word = data[-(j+1)] + word
        
        for j in reversed(word):
            c += 1
            a = j + a
            if check > c:
                continue
            if a != stock2:
                stock2 = a
                data2.insert(0,a)
                a = ""
        if len(data2)>=2:
            if (len(S)<=i+2) and (data2[0]!=data2[1]) and (a == ""):
                count = len(data2)
                break
            elif len(S)<=i+2:
                check += 1
                if check == len(S):
                    count = 1
                    break
                continue
        elif (len(data2)==1) and (a==""):
            if S==data2[0]:
                count = 1
                break
            else:
                i += 1
                continue
        elif len(data2)==1:
            check += 1
            continue
        if (data2[0] != data[-(i+2)]) and (a == ""):
            count = len(data) - (i+1) + len(data2)
            break
        i += 1
        

print(count)
Buggy code:
s = input()
lst = []

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

q = 0
while q <= len(s)-2:
    if s[q] == s[q+1]:
        lst.append(s[q])
        if q+1 != len(s)-1:
            lst.append(s[q+1:q+3])
        q += 3
    else:
        lst.append(s[q])
        q += 1
else:
    ans = len(lst)
    text = str(lst).replace('[','').replace(']','').replace(',','').replace("'",'').replace(" ",'')
    if text != s:
        ans += 1
print(ans)

Fixed code:
s = input()
lst = []

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

q = 0
while q <= len(s)-2:
    if s[q] == s[q+1]:
        lst.append(s[q])
        if q+1 != len(s)-1:
            lst.append(s[q+1:q+3])
        q += 3
    else:
        lst.append(s[q])
        q += 1
else:
    ans = len(lst)
    text = str(lst).replace('[','').replace(']','').replace(',','').replace("'",'').replace(" ",'')
    if text != s and s[-1] != lst[-1]:
        ans += 1
print(ans)
Buggy code:
S = input()
previous_c = S[0]
present_c = ""
total_count = 1
for c in S[1:]:
    present_c += c
    if present_c != previous_c:
        print(previous_c)
        total_count += 1
        previous_c = present_c
        present_c = ""

    else:
        pass
print(total_count)


Fixed code:
S = input()
previous_c = S[0]
present_c = ""
total_count = 1
for c in S[1:]:
    present_c += c
    if present_c != previous_c:
        total_count += 1
        previous_c = present_c
        present_c = ""

    else:
        pass
print(total_count)
Buggy code:
i = input()

prev = ""
res = 0
index = 0
while index < len(i):
    temp = i[index]
    if temp == prev:
        prev = i[index:index+2]
        index += 2
    else:
        prev = i[index]
        index += 1
    res += 1

print(res)

Fixed code:
i = input()

prev = ""
res = 0
index = 0
while index < len(i):
    temp = i[index]
    if temp == prev:
        prev = i[index:index+2]
        if index == len(i)-1:
            res -= 1
        index += 2

    else:
        prev = temp
        index += 1

    res += 1

print(res)
Buggy code:
s=list(input())
c=1
i=1
f=1
w=[s[0]]
while i<len(s)-1:
    if s[i]==s[i-1] and f:
        w.append(s[i]+s[i+1])
        i+=1
        c+=1
        i+=1
        f=0
    else:
        w.append(s[i])
        f=1
        c+=1
        i+=1
if s[-1]!=w[-1]:
    w.append(s[-1])
print(w)


Fixed code:
s=list(input())
i=1
f=1
w=[s[0]]
while i<len(s)-1:
    if s[i]==s[i-1] and f:
        w.append(s[i]+s[i+1])
        i+=1
        i+=1
        f=0
    else:
        w.append(s[i])
        f=1
        i+=1
if s[-1]!=w[-1] and i<len(s):
    w.append(s[-1])
print(len(w))
Buggy code:
n = list(input())
ans = 0
idx = 0
res = []
flag = 0
while True:
  if idx == 0:
    res.append(n[idx])
    idx += 1
  elif idx == len(n)-1:
    if res[-1] == n[idx]:
      pass
    else:
      res.append(n[idx])    
    flag = 1
  elif res[-1] == n[idx]:
    res.append(n[idx]+n[idx+1])
    idx += 2
  else:
    res.append(n[idx])
    idx += 1
  if idx == len(n):
    flag = 1
  if flag:
    break
  
print(len(res),res)

Fixed code:
n = list(input())
ans = 0
idx = 0
res = []
flag = 0
while True:
  if idx == 0:
    res.append(n[idx])
    idx += 1
  elif idx == len(n)-1:
    if res[-1] == n[idx]:
      pass
    else:
      res.append(n[idx])    
    flag = 1
  elif res[-1] == n[idx]:
    res.append(n[idx]+n[idx+1])
    idx += 2
  else:
    res.append(n[idx])
    idx += 1
  if idx == len(n):
    flag = 1
  if flag:
    break
  
print(len(res))
Buggy code:
s = input()
skip = False
ans = [s[0]]
n = 0
for i in range(len(s))[1:]:
    if skip == True:
        skip = False
        continue
    elif ans[n] == s[i] and i+1 < len(s):
        ans.append(s[i]+s[i+1])
        skip = True
        n += 1
    else:
        ans.append(s[i])
        n += 1
print(len(ans))

Fixed code:
s = input()
skip = False
ans = [s[0]]
n = 0
for i in range(len(s))[1:]:
    if skip == True:
        skip = False
        continue
    elif ans[n] == s[i] and i+1 < len(s):
        ans.append(s[i]+s[i+1])
        skip = True
        n += 1
    else:
        ans.append(s[i])
        n += 1
res = len(ans)
if ans[-1] == ans[-2]:
    res -= 1
print(res)
Buggy code:
s = list(input())
count = 0
check = 0
tem = str()

for i in range(0,len(s)):
    if check >0:
        check -= 1
        count += 1
    if check != 0:
        count -= 1
        continue
    if tem == "" or tem != s[i] :
        count += 1
        print(tem)
        tem = s[i]
    else:
        check = 2
        print(tem+s[i])
        tem = str()
print(count)

Fixed code:
s = list(input())
count = 0
check = 0
tem = str()

for i in range(0,len(s)):
    if check == 2:
        check = 1
        count += 1
        continue
    if check == 1:
        check = 0

    if tem == "" or tem != s[i]:
        count += 1
        tem = s[i]
    else:
        check = 2
        tem = str()
print(count)
Buggy code:
def main():
    s = input()

    cnt = 0
    restore = []
    i = 0
    length = len(list(s))
    while i < length:
        if i == 0:
            restore.append(s[i])
            cnt += 1
            i += 1
        else:
            j = 0
            while j < length:
                if  j == 0:
                    string = s[i]
                else:
                    string = s[i:i+j+1]
                if restore[-1] == string:
                    j += 1
                else:
                    cnt += 1
                    print(string)
                    restore.append(string)
                    break
            i += j + 1
    print(restore)
    print(cnt)
 
if __name__ == '__main__':
    main()

Fixed code:
def main():
    s = input()

    cnt = 0
    restore = []
    i = 0
    length = len(list(s))
    while i < length:
        if i == 0:
            restore.append(s[i])
            cnt += 1
            i += 1
        else:
            j = 0
            while j < length:
                if  j == 0:
                    string = s[i]
                else:
                    string = s[i:i+j+1]
                if restore[-1] == string:
                    j += 1
                else:
                    cnt += 1
                    #print(string)
                    restore.append(string)
                    break
            i += j + 1
    #print(restore)
    print(cnt)
 
if __name__ == '__main__':
    main()
Buggy code:
S = input()
N = len(S)

ans_l = 0
idx = 0
tmp = S[0]
while idx < N:
    for i in range(N-1):
        if i + idx > N-1:
            break
        if tmp != S[idx:idx+i+1]:
            ans_l += 1
            tmp = S[idx:idx+i+1]
            print(tmp)
            break
    idx += (i+1)

print(ans_l)



Fixed code:
S = input()
N = len(S)

ans_l = 1
idx = 1
tmp = S[0]
while idx < N:
    for i in range(N-1):
        if tmp != S[idx:idx+i+1]:
            ans_l += 1
            tmp = S[idx:idx+i+1]
            break
        if i + idx == N-1:
            break
    idx += (i+1)

print(ans_l)
Buggy code:
S = input()
c = 0
S += ".."
while S[0] != ".":
    if S[0] != S[1]:
        c += 1
        S = S[1:]
    else:
        c += 2
        S = S[3:]
print(c)

Fixed code:
S = input()
c = 0
S += ".."
while S[0] != ".":
    if S[0] != S[1]:
        c += 1
        S = S[1:]
    else:
        c += 2
        S = S[3:]
print(c+len(S)-2)
Buggy code:
S = input()
count = 0
i = 0
while i < len(S)-2:
    if S[i] == S[i+1]:
        print(S[i])
        print(S[i+1]+S[i+2])
        i +=3
        count += 2  
    else:
        print(S[i])
        i +=1
        count += 1
if S[i] == S[i+1]:
    count += 1
else:
    count += 2
print(count)

Fixed code:
S=input()

ans = 0
count=0
while count <= len(S)-2:
    if S[count]==S[count+1]:
        count = count+3
        ans+=2
        if count == len(S):
            ans -= 1
        if count == len(S)+1:
            ans -= 2

    else:
        count = count+1
        ans +=1


print(ans+1)
Buggy code:
S = input()

res = 0
p = ''
now = ''
for x in S:
    now += x
    if p != now:
        print(now)
        res += 1
        p = now
        now = ''

print(res)


Fixed code:
S = input()

res = 0
p = ''
now = ''
for x in S:
    now += x
    if p != now:
        #print(now)
        res += 1
        p = now
        now = ''

print(res)
Buggy code:
s = input()
now = 0
ans = 1
LEN = len(s)
while now <= LEN-2:
  if s[now] == s[now+1]:
    now += 2
    if now >= LEN:
      break
  else:
    now += 1
  ans += 1
print(ans)

Fixed code:
s = input()
now = 0
t = 0
ans = 1
LEN = len(s)
while now <= LEN-2:
  if s[now] == s[now+1] and t == 0:
    now += 2
    if now >= LEN:
      break
    t = 1
  else:
    now += 1
    t = 0
  ans += 1
print(ans)
Buggy code:
s = input()

ans = 0
p = "0"
q = ""
for i in range(len(s)):
    if p == "0":
        ans += 1
        p = s[i]
        continue

    q += s[i]
    if q == p:
        continue
    else:
        ans += 1
        p = s[i]
        q = ""

print(ans)
        
    
        
        

                                        




    




        


    







        



Fixed code:
s = input()

ans = 0
p = "0"
q = ""
for i in range(len(s)):
    if p == "0":
        ans += 1
        p = s[i]
        continue

    q += s[i]
    if q == p:
        continue
    else:
        ans += 1
        p = q
        q = ""
        
print(ans)