ZhenlongDai/ACPR huggingface dataset:
Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S=input()
ret = set([])
tmp = ''
for i in range(len(S)):
  tmp += S[i]
  if tmp in ret:
    continue
  else:
    ret.add(tmp)
    tmp=''
print(len(ret))

Failing test case input:
^`b^``

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
S=input()
ret = ['']
tmp = ''
for i in range(len(S)):
  tmp += S[i]
  if tmp == ret[-1]:
    continue
  else:
    ret.append(tmp)
    tmp=''
print(len(ret)-1)

Problem: p02939
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = list(input())
i = len(s)
p = 0
while i >= 3:
    if s[i-1] == s[i-2]:
        i -= 3
        p += 2
    else:
        i -= 1
        p += 1

if i == 0:
    print(p)
else:
    if s[i-1] == s[i-2]:
        print(p+1)
    else:
        print(p+2)

Failing test case input:
`bbbc`aabbaabbb

Expected output:
11


Actual output:
12


Fixed submission (verdict: Accepted):
s = list(input())
i = len(s)
p = 0
while i >= 3:
    if s[i-1] == s[i-2]:
        i -= 3
        p += 2
    else:
        i -= 1
        p += 1

if i <= 1:
    print(p+i)
else:
    if s[i-1] == s[i-2]:
        print(p+1)
    else:
        print(p+2)

Problem: p02939
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    S=input()
    n=len(S)
    ans=0
    now=0
    cnt=2
    while(now<n):
        if(cnt==2):
            ans+=1
            cnt=1
            now+=1
        else:
            if(S[now]!=S[now-1]):
                ans+=1
                now+=1
            else:
                cnt=2
                now+=1
    print(ans+(cnt==2))
resolve()

Failing test case input:
```b^^

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    S=input()
    n=len(S)

    if(n==1):
        print(1)
        return
    if(n==2):
        print(len(set(S)))
        return

    dp=[None]*(n+1)
    dp[0]=0
    dp[1]=1
    dp[2]=len(set(S[:2]))

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

    print(dp[-1])
resolve()
Problem: p02939
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
ss = input()+'**'
n = len(ss)
arrs = [ss[0]]

for i in range(1, n):
  if len(arrs[-1]) == 2:
    if arrs[-1].endswith(ss[i]):
      continue
    else:
      arrs.append(ss[i])
  else:
    if ss[i-1] == ss[i]:
      arrs.append(ss[i: i+2])
    else:
      arrs.append(ss[i])
while '*' in arrs:
  arrs.remove('*')

print(arrs)
print(len(arrs)) 

Failing test case input:
abbbcaaabaababc

Expected output:
12


Actual output:
['a', 'b', 'bb', 'c', 'a', 'aa', 'b', 'a', 'ab', 'a', 'b', 'c']
12


Fixed submission (verdict: Accepted):
ss = input()

n = len(ss)
arrs = [ss[0]]

for i in range(1, n):
    if len(arrs[-1]) == 2:
        if arrs[-1].endswith(ss[i]):
            arrs.append('*')
        else:
            arrs.append(ss[i])

    else:
        if arrs[-1] == ss[i]:
            arrs.append(ss[i: i + 2])
        else:
            arrs.append(ss[i])

c = arrs.count('*')

if arrs[-1] == arrs[-2]:
    ans = len(arrs) - 1

else:
    ans = len(arrs)
print(ans - c)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = list(input())
ans_1 = 1
ans_2 = 1
i = 0
while i < len(s)-1:
  
  if i == len(s)-2 and s[i] == s[i+1]:
    break
    
  elif s[i] == s[i+1]:
    i += 2
    ans_1 += 1
  else:
    i += 1
    ans_1 +=1
    
k = 1
while k < len(s)-1:
  if s[k] == s[k+1]:
    k += 2
    ans_2 += 1
  else:
    k += 1
    ans_2 +=1
print(max(ans_1,ans_2))

Failing test case input:
bbbaabba``cabb`

Expected output:
11


Actual output:
10


Fixed submission (verdict: Accepted):
s = list(input())
ans_1 = 1
ans_2 = 1
i = 0
while i < len(s)-1:
  
  if i == len(s)-2 and s[i] == s[i+1]:
    break
    
  elif i == len(s)-3 and s[len(s) - 3] == s[len(s) - 2]:
    ans_1 += 1
    break
  elif s[i] == s[i+1]:
    i += 3
    ans_1 += 2
  else:
    i += 1
    ans_1 +=1
    
k = 1
while k < len(s)-1:
  
  if k == len(s)-2 and s[k] == s[k+1]:
    break
  elif k == len(s)-3 and s[len(s) - 3] == s[len(s) - 2]:
    ans_2 += 1
    break
  elif s[k] == s[k+1]:
    k += 3
    ans_2 += 2
  else:
    k += 1
    ans_2 +=1
print(max(ans_1,ans_2))

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
i = 0
parts = [S[0]]
parts_append = parts.append
while i < len(S) - 1:
    print(parts[-1], S[i + 1])
    if S[i + 1] == parts[-1]:
        parts_append(S[i + 1:i + 3])
        i += 2
    else:
        parts_append(S[i + 1])
        i += 1

print(len(parts) - (1 if i == len(S) else 0))

Failing test case input:
```aaa

Expected output:
4


Actual output:
` `
`` a
a a
4


Fixed submission (verdict: Accepted):
S = input()
i = 0
parts = [S[0]]
parts_append = parts.append
while i < len(S) - 1:
    if S[i + 1] == parts[-1]:
        parts_append(S[i + 1:i + 3])
        i += 2
    else:
        parts_append(S[i + 1])
        i += 1

print(len(parts) - (1 if i == len(S) else 0))
Problem: p02939
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()

ans = 0
pre = ""
now = ""

for c in s:
    now += c

    if pre == now:
        pre += now
    else:
        ans += 1
        pre = now
        now = ""
print(ans)


Failing test case input:
abbccaaabaababc

Expected output:
12


Actual output:
11


Fixed submission (verdict: Accepted):
s = input()

ans = 0
pre = ""
now = ""

for c in s:
    now += c

    if pre == now:
        continue
    else:
        ans += 1
        pre = now
        now = ""
print(ans)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
a = S[0]
count = 1
flag = 1
if len(S) == 1:
    print(1)
else:
    for i in range(1, len(S)):
        if a != S[i] or flag == 0:
            count += 1
            flag = 1
        else:
            flag = 0
        a = S[i]
    print(count)

Failing test case input:
abbbb`acbcababb

Expected output:
13


Actual output:
12


Fixed submission (verdict: Accepted):
S = input()
a = S[0]
count = 1
flag = 1
if len(S) == 1:
    print(1)
else:
    for i in range(1, len(S)):
        if flag == 0:
            flag = 1
            a = "A"
            continue
        if a != S[i]:
            count += 1
        else:
            if i != len(S) - 1:
                count += 1
            flag = 0
        
        a = S[i]
    print(count)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()

loop = True
index = 1
ans = 1
stmp = S[0]
while loop:
    if index == len(S):
        break
    stmp += S[index]
    if stmp == S[index - 1]:
        index += 1
        continue
    else:
        ans += 1
        index += 1
        stmp = ''
print(ans)

Failing test case input:
``b^`^

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
S = input()

loop = True
index = 1
ans = 1
stmp = S[0]
cnt = 1
while loop:
    if index == len(S):
        break
    if stmp == S[cnt: index + 1]:
        index += 1
        continue
    else:
        ans += 1
        index += 1
        stmp = S[cnt: index]
        cnt = index
print(ans)

Problem: p02939
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
S = input()
ans = []
cur = ''


for i in range(len(S)):
    cur += S[i]

    if len(ans) == 0:
        ans.append(cur)
        cur = ''
    else:
        if ans[len(ans)-1] != cur:
            ans.append(cur)
            cur = ''

print(ans)


Failing test case input:
`_ca_`

Expected output:
6


Actual output:
`, _, c, a, _, `

Fixed submission (verdict: Accepted):
S = input()
ans = []
cur = ''


for i in range(len(S)):
    cur += S[i]

    if len(ans) == 0:
        ans.append(cur)
        cur = ''
    else:
        if ans[len(ans)-1] != cur:
            ans.append(cur)
            cur = ''

print(len(ans))
Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

S = input()
L = [alphabet for alphabet in S]
moji1 = L[0]
moji2 = ''
i = 1
res = 0
while i < len(L):
  if moji1 == moji2:
    moji2 += L[i]
    i+=1
  else:
    res += 1
    moji1 = moji2
    moji2 = L[i]
    i += 1
print(res)

Failing test case input:
`bbac``abbaabbb

Expected output:
11


Actual output:
10


Fixed submission (verdict: Accepted):

S = input()
L = [alphabet for alphabet in S]
i = 0
k = 1
before = ''
res = 0
while i+k <= len(L):
  if L[i:i+k] != before:
    res += 1
    before = L[i:i+k] 
    i = i+k 
    k = 1 
  else:
    k += 1
print(res)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
k=0
i=0
sec=0
while i < len(s)-1:
  if i==0:
    i+=1
    k+=1
  if sec==0:
    i+=1
    k+=1
    sec=1
  else:
    if s[i-1]==s[i]:
      i+=2
      k+=1
      sec=0
    else:
      i+=1
      k+=1
  
print(k)

Failing test case input:
`_``_c

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
s = input()
k=0
i=0
itimoji=0
while i <len(s):
  if i==0:
    k+=1
    i+=1
    itimoji=1
    continue
  if itimoji==0:
    k+=1
    i+=1
    itimoji=1
  else: 
    if s[i]==s[i-1]:
      if i==len(s)-1:
        break
      else:
        i+=2
        k+=1
        itimoji=0
    else:
      i+=1
      k+=1

print(k)

Problem: p02939
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = input()
    n = len(s)

    prev = ""
    ans = 0
    i = 0
    while i < n:
        if s[i] == prev:
            if i + 2 < n:
                ans += 1
                prev = s[i] + s[i+1]
                i += 2
            else:
                i += 2
        else:
            ans += 1
            prev = s[i]
            i += 1
    print(ans)


if __name__ == '__main__':
    main()


Failing test case input:
``a``a

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = input()
    n = len(s)

    prev = ""
    ans = 0
    i = 0
    while i < n:
        if s[i] == prev:
            if i + 1 < n:
                ans += 1
                prev = s[i] + s[i+1]
                i += 2
            else:
                i = n
        else:
            ans += 1
            prev = s[i]
            i += 1
    print(ans)


if __name__ == '__main__':
    main()
Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
N = len(S)
count = 0
i = 0
last = ""

while i < N:
    if i == 0:
        last = S[i]
        i += 1
        count += 1
    elif i != 0 and last == S[i]:
        if i > N-2:
            break
        last = S[i:i+2]
        i += 2
        count += 1
    elif i != 0 and last != S[i]:
        last = S[i]
        i += 1
        count += 1
    print(i)
    print(last)
if i == N-1 and last != S[N-1]:
    count += 1
print(count)


Failing test case input:
``aabadbc_bacb_

Expected output:
14


Actual output:
1
`
3
`a
4
a
5
b
6
a
7
d
8
b
9
c
10
_
11
b
12
a
13
c
14
b
15
_
14


Fixed submission (verdict: Accepted):
S = input()
N = len(S)
count = 0
i = 0
last = ""

while i < N:
    if i == 0:
        last = S[i]
        i += 1
        count += 1
    elif i != 0 and last == S[i]:
        if i > N-2:
            break
        last = S[i:i+2]
        i += 2
        count += 1
    elif i != 0 and last != S[i]:
        last = S[i]
        i += 1
        count += 1

if i == N-1 and last != S[N-1]:
    count += 1
print(count)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def calc(pr, s):
    cnt = 0
    i = 0
    while i < len(s)-1:
        if len(pr) == 1:
            if s[i+1] == pr:
                if i+2 < len(s)-1:
                    cnt += 1
                    pr = s[i+1:i+3]
                    i += 1
                else:
                    break
            else:
                cnt += 1
                pr = s[i+1]
                i += 1
        else:
            cnt += 1
            if i+2 < len(s)-1:
                pr = s[i+2]
                i += 2
            else:
                break
    return cnt+1

s = input()
pr1 = s[0]
pr2 = s[:2]
print(max(calc(pr1, s), calc(pr2, s)))

Failing test case input:
`^b``^

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
def calc(pr, s):
    cnt = 0
    i = 0
    while i < len(s)-1:
        if len(pr) == 1:
            if s[i+1] == pr:
                if i+2 < len(s):
                    cnt += 1
                    pr = s[i+1:i+3]
                    i += 1
                else:
                    break
            else:
                cnt += 1
                pr = s[i+1]
                i += 1
        else:
            if i+2 < len(s):
                cnt += 1
                pr = s[i+2]
                i += 2
            else:
                break
    return cnt+1

s = input()
pr1 = s[0]
pr2 = s[:2]
print(max(calc(pr1, s), calc(pr2, s)))

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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
		else:
			it += 3
			con += 2
	else:
		it += 1
		con += 1
print(con)

Failing test case input:
`_c``_

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
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)
Problem: p02939
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
S = input()
tmp = S[0]
now = ""
ans = 0
for i in range(len(S)):
    now += S[i]
    if tmp != now:
        ans += 1
        tmp = now
        now = ""
print(ans)


Failing test case input:
abbbb`acbcababb

Expected output:
13


Actual output:
12


Fixed submission (verdict: Accepted):
S = input()
tmp = S[0]
now = ""
ans = 1
for i in range(1, len(S)):
    now += S[i]
    if tmp != now:
        ans += 1
        tmp = now
        now = ""
print(ans)

Problem: p02939
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def main():
    S = input()
    dp_1 = [0] * len(S)
    dp_2 = [0] * len(S)
    if S[0] != S[1]:
        dp_1[0] = 1
        dp_1[1] = 1
    dp_2[1] = 1
    for i, v in enumerate(S):
        if i < 2:
            continue
        if v == S[i-1]:
            dp_1[i] = dp_2[i-1] + 1
        else:
            dp_1[i] = max(dp_1[i-1], dp_2[i-1]) + 1
        if i < 4 or S[i-1:i+1] == S[i-3:i-1]:
            dp_2[i] = dp_1[i-2] + 1
        else:
            dp_2[i] = max(dp_1[i-2], dp_2[i-2]) + 1
    return max(dp_1[-1], dp_2[-1])
print(main())


Failing test case input:
a``aa`

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
def main():
    S = input()
    if S == 1:
        return 1
    dp_1 = [0] * len(S)
    dp_2 = [0] * len(S)
    if S[0] != S[1]:
        dp_1[1] = 2
    dp_1[0] = 1
    dp_2[1] = 1
    for i, v in enumerate(S):
        if i < 2:
            continue
        if v == S[i-1]:
            dp_1[i] = dp_2[i-1] + 1
        else:
            dp_1[i] = max(dp_1[i-1], dp_2[i-1]) + 1
        if i < 4 or S[i-1:i+1] == S[i-3:i-1]:
            dp_2[i] = dp_1[i-2] + 1
        else:
            dp_2[i] = max(dp_1[i-2], dp_2[i-2]) + 1
    return max(dp_1[-1], dp_2[-1])
print(main())

Problem: p02939
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S=input()
tmp=S[0]
i=1
ans=1
while i<len(S):
    
    if S[i]!=tmp:
        ans+=1
        tmp=S[i]
        i+=1
    else:
        ans+=1
        tmp=S[i:i+2]
        i+=2
if S[-2]==S[-1]:
    ans-=1
print(ans)

Failing test case input:
c`aaaa

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
S=input()
tmp=S[0]
i=1
ans=1
while i<len(S)-1:
    
    if S[i]!=tmp:
        ans+=1
        tmp=S[i]
        i+=1
    else:
        ans+=1
        tmp=S[i:i+2]
        i+=2
if i>=len(S):
    print(ans)
elif tmp==S[i]:
    print(ans)
else:
    print(ans+1)
Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
Slength = len(S)
current = S[0] 
i = 1
ans = 1
while i < Slength:
    judge = True
    j = 0
    while judge:


        if current == S[i:i+j+1]:
            j += 1
            
            if i+j+1>=Slength:
                ans -= 1 
                break
            else:
                pass
            
        else:
            current = S[i:i+j+1]
            judge = False
    i += j + 1
    ans += 1


print(ans)

Failing test case input:
`bbbc``abbaabbb

Expected output:
11


Actual output:
10


Fixed submission (verdict: Accepted):
S = input()
Slength = len(S)
current = S[0] 
i = 1
ans = 1
while i < Slength:
    judge = True
    j = 0
    while judge:


        if current == S[i:i+j+1]:
            
            if i+j+1>=Slength:
                ans -= 1 
                break
            else:
                pass
            
            j += 1
        else:
            current = S[i:i+j+1]
            judge = False
    i += j + 1
    ans += 1


print(ans)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    S = input()

    ans = 0
    tmp = ''
    pre = ''
    for s in S[1:]:
        tmp += s
        if tmp != pre:
            pre = tmp
            tmp = ''
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Failing test case input:
a`aa_`

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
def main():
    S = input()

    ans = 0
    tmp = ''
    pre = ''
    for s in S:
        tmp += s
        if tmp != pre:
            pre = tmp
            tmp = ''
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Problem: p02939
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
 
s = readChar()
if len(s)==1:
	print(1)
	exit()
b="-1"
ans=0
l = [""]
while len(s)>1:
	if l[-1]!=s[:1]:
		l.append(s[:1])
		s = s[1:]
	else:
		l.append(s[:2])
		s = s[2:]
if s!="":
	l.append(s)
del l[0]

print(l)
if l[-1]==l[-2]:
	del l[-1]

print(len(l))

Failing test case input:
a``a``

Expected output:
4


Actual output:
['a', '`', '`a', '`', '`']
4


Fixed submission (verdict: Accepted):
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
 
s = readChar()
if len(s)==1:
	print(1)
	exit()
b="-1"
ans=0
l = [""]
while len(s)>1:
	if l[-1]!=s[:1]:
		l.append(s[:1])
		s = s[1:]
	else:
		l.append(s[:2])
		s = s[2:]
if s!="":
	l.append(s)
del l[0]


if l[-1]==l[-2]:
	del l[-1]

print(len(l))
Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
ans=0
k=0
k2=[]
k1=[]
for i in range(len(s)-1):
    if s[i]!=s[i+1] :
        k1.append(s[k:i+1])
        
        if k1!=k2:
            if  k2:
                del k2[0]
            k2.append(k1[0])
            del k1[0]
            ans+=1
        k=i+1
    
        
    
if ans==0:
    ans=1
elif ans==1:
    ans=2
else:
    ans=ans+2
print(ans)

Failing test case input:
a``a``

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
s=input()
ans=0
k=0
k2=[]
k1=[]
s1=""
i=0
while i<len(s) :
    for j in range(i,len(s)):
        if s1==s[i:j+1]:
            continue
        else:
            s1=s[i:j+1]
            
            ans+=1
            i=j
            break
    i+=1

        
    
if ans==0:
    ans=1


print(ans)

Problem: p02939
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = str(input())
ans = ''
ans2 = ''
con = 0
for s in S:
  ans += s
  if s != ans2:
    if ans != ans2:
      con += 1
      ans2 = ans
      ans = ''
print(con)
      


Failing test case input:
b`aaaa

Expected output:
5


Actual output:
3


Fixed submission (verdict: Accepted):
S = str(input())
ans = ''
ans2 = ''
con = 0
for s in S:
  ans += s
  if ans != ans2:
    con += 1
    ans2 = ans
    ans = ''
print(con)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


s=input()

t=""

i=1

c=0

while(i<len(s)):
	if(s[i]==t):
		i+=1
		if(i<len(s)):
			t+=s[i]
			c+=1
	else:
		t=s[i]
		c+=1

	i+=1

print(c)


Failing test case input:
```aaa

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):


s=input()

t=""

i=0

c=0

while(i<len(s)):
	if(s[i]==t):
		i+=1
		if(i<len(s)):
			t+=s[i]
			c+=1
	else:
		t=s[i]
		c+=1
	i+=1

print(c)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
abbba`acbcababb

Expected output:
13


Actual output:
14


Fixed submission (verdict: Accepted):
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)
Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
ans = 1
now = S[0]
flag = False
for i in range(1, len(S)-1):
    if flag:
        flag = False
        continue
    if len(now) == 1:
        if S[i] == now:
            ans += 1
            now = S[i] + S[i+1]
            flag = True
        else:
            ans += 1
            now = S[i]
    else:
        ans += 1
        now = S[i]
if S[-1] != now:
    ans += 1
print(ans)

Failing test case input:
`^b``^

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
S = input()
ans = 1
now = S[0]
flag = False
for i in range(1, len(S)-1):
    if flag:
        flag = False
        continue
    if len(now) == 1:
        if S[i] == now:
            ans += 1
            now = S[i] + S[i+1]
            flag = True
        else:
            ans += 1
            now = S[i]
    else:
        ans += 1
        now = S[i]
if not flag and S[-1] != now:
    ans += 1
print(ans)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()

ans = 1
tmp = s[0]
t = False

for i in range(1, len(s)):
    if tmp == s[i] and i == len(s) - 1:
        break
        
    if t:
        tmp = s[i - 1] + s[i]
        t = False
        ans += 1
        continue
        
    if tmp == s[i]:
        t = True
        
    else:
        ans += 1
        tmp = s[i]

print(ans)
    

Failing test case input:
aaa```

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
s = input()

ans = 1
tmp = s[0]
t = False

for i in range(1, len(s)):
    if t:
        tmp = s[i - 1] + s[i]
        t = False
        ans += 1
        continue
        
    if tmp == s[i]:
        t = True
        
    else:
        ans += 1
        tmp = s[i]

print(ans)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def A_DividingaString():
    S = input()
    ans = 0
    tmp,last = "", ""
    for s in S:
        tmp += s
        if s != last:
            last = tmp
            tmp = ""
            ans += 1
    print(ans)
    
if __name__ == "__main__":
    A_DividingaString()

Failing test case input:
abbbc`aabcababb

Expected output:
12


Actual output:
11


Fixed submission (verdict: Accepted):
def A_DividingaString():
    S = input()
    ans = 0
    tmp,last = "", ""
    for s in S:
        tmp += s
        if tmp != last:
            last = tmp
            tmp = ""
            ans += 1
    print(ans)
    
if __name__ == "__main__":
    A_DividingaString()

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
_bcab_cbdabaa``

Expected output:
14


Actual output:
13


Fixed submission (verdict: Accepted):
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)
Problem: p02939
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = open(0).read().rstrip()
n = len(s)

from collections import defaultdict
ans = defaultdict(int)
ans[-2] = -1
ans[-1] = -1
ans[0] = 1

for i in range(1,n):
    if s[i] != s[i-1]:
        ans[i] = ans[i-1]+1
    else:
        ans[i] = ans[i-3]+2

print(ans[n-1])

Failing test case input:
a``a``

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
s = open(0).read().rstrip()
n = len(s)

from collections import defaultdict
ans = defaultdict(int)
ans[-2] = -1
ans[-1] = 0
ans[0] = 1

for i in range(1,n):
    if s[i] != s[i-1]:
        ans[i] = ans[i-1]+1
    else:
        ans[i] = ans[i-3]+2

print(ans[n-1])

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
from heapq import *
sys.setrecursionlimit(200000)
input = sys.stdin.readline

S = list(input().strip())
before = S[0]
index = 1
c = 0
a = ""

while index < len(S):
    a += before
    if before != S[index]:
        before = S[index]
        index += 1
    else:
        before = "".join(S[index:index+2])
        index += 2

    c += 1

if a != S:
    if S[-1] != S[-2]:
        c += 1
print(c)

Failing test case input:
a`bbaa

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
import sys
from heapq import *
sys.setrecursionlimit(200000)
input = sys.stdin.readline

S = list(input().strip())
L = []
L.append(S[0])

index = 0
index_a = 1
while index_a < len(S):
    if L[index] != S[index_a]:
        L.append(S[index_a])
        index += 1
        index_a += 1
    else:
        c = "".join(S[index_a:index_a+2])
        if L[index] == c:
            L[index] += c
        else:
            L.append(c)
        index += 1
        index_a += 2

print(len(L))

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
N = len(S)

dp = [0 for _ in range(N)]

dp[0] = 1
dp[1] = 1

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

print(dp[N - 1])


Failing test case input:
_`ba_a

Expected output:
6


Actual output:
5


Fixed submission (verdict: Accepted):
S = input()
N = len(S)

dp = [0 for _ in range(N)]

dp[0] = 1
dp[1] = 2 if S[0] != S[1] else 1

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

print(dp[-1])

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin

def main():
    S = input()

    prev = ''
    ans = 1
    for i in range(1, len(S)):
        if prev != S[i]:
            ans += 1
            prev = S[i]
        else:
            prev += S[i]
    print(ans)

input = lambda: stdin.readline().rstrip()
main()


Failing test case input:
bbbaabba``cabb`

Expected output:
11


Actual output:
10


Fixed submission (verdict: Accepted):
from sys import stdin

def main():
    S = input()

    prev, now = S[0], ''
    ans = 1
    for i in range(1, len(S)):
        now += S[i]
        if prev != now:
            ans += 1
            prev, now = now, ''
    print(ans)

input = lambda: stdin.readline().rstrip()
main()
Problem: p02939
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import deque
def main3():
    S = input()

    i = 0
    tmp = ""
    sub = deque()
    words = set()
    while True:
        j = 1
        while i + j <= len(S):
            if S[i:i+j] != tmp:
                sub.append(S[i:i+j])
                tmp = S[i:i+j]
                i = i + j
                
                break
            else:
                j += 1

        if i + j > len(S):
            
            if S[i:i+j] != "":
                e = sub.pop()
                sub.append(e+S[i:i+j])
            break
    
    
    print(len(sub))
    
if __name__ == "__main__":
    main3()

Failing test case input:
b`aa`a

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
from collections import deque
def main3():
    S = input()

    i = 0
    tmp = ""
    sub = deque()
    words = set()
    while True:
        j = 1
        while i + j <= len(S):
            if S[i:i+j] != tmp:
                sub.append(S[i:i+j])
                tmp = S[i:i+j]
                i = i + j
                
                break
            else:
                j += 1

        if i + j > len(S):
            
            if S[i:i+j] != "":
                if sub[-1] == S[i:i+j]:
                    e = sub.pop()
                    sub.append(e + S[i:i+j])
                else:
                    sub.append(S[i:i+j])
            break
    
    
    print(len(sub))
    
if __name__ == "__main__":
    main3()

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()

dif = 0
i = 1
last = S[0]
while i < len(S):
    print(last, S[i])
    if last!=S[i]:
        last = S[i]
        i += 1
    else:
        last = ''.join(S[i:i+2])
        i += 2
        dif += 1

print(len(S)-dif)

Failing test case input:
`bbab`cabba`c`b

Expected output:
13


Actual output:
` b
b b
ba b
b `
` c
c a
a b
b b
ba `
` c
c `
` b
13


Fixed submission (verdict: Accepted):
S = input()

dif = 0
i = 1
last = S[0]
while i < len(S):
    if last!=S[i]:
        last = S[i]
        i += 1
    else:
        last = ''.join(S[i:i+2])
        i += 2
        dif += 1

print(len(S)-dif)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
N = len(S)
k = 0
pc = ""
i = 0
while i<N:
    c = S[i]
    i += 1
    if c==pc:
        if i==N:
            break
        while c==pc:
            c += S[i]
            i += 1
            if i==N:
                break
        else:
            k += 1
            pc = c
    else:
        k += 1
        pc = c
print(k)


Failing test case input:
bbbaabba``cabb`

Expected output:
11


Actual output:
10


Fixed submission (verdict: Accepted):
S = input()
N = len(S)
k = 0
pc = ""
i = 0
while i<N:
    c = S[i]
    i += 1
    if c==pc:
        if i==N:
            break
        while c==pc:
            if i==N:
                break
            c += S[i]
            i += 1
        else:
            k += 1
            
            pc = c
    else:
        k += 1
        
        pc = c
print(k)
Problem: p02939
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()

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


now = s[0]
cnt = 1
i = 1
while True:
    if s[i] != now:
        cnt += 1
        now = s[i]
        i += 1
    else:
        now = now + s[i]
        cnt += 1
        i += 2
        if i > len(s)-1:
            cnt -= 1
    if i >= len(s):
        break
print(cnt)

Failing test case input:
aaa```

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
s = input()

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


now = s[0]
cnt = 1
i = 1
while True:
    if s[i] != now:
        cnt += 1
        now = s[i]
        i += 1
    else:
        now = now + s[i]
        cnt += 1
        i += 2
        if i > len(s):
            cnt -= 1
    if i >= len(s):
        break
print(cnt)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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])

Failing test case input:
`bbab`cabba`c`b

Expected output:
13


Actual output:
11


Fixed submission (verdict: Accepted):
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])

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A = input()
B=1
try:
        for i in range(len(A)):
            if A[-1] != A[-2]:
                B += 1
                A = A[:-1]
            elif A[-1] == A[-2] and A[-2] == A[-3]:
                B += 2
                A = A[:-3]
            else:
                B += 2
                A = A[:-3]
except IndexError:
    print(B)

Failing test case input:
b``aaa

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
A = input()
B=1
try:
    for i in range(len(A)):
        if A[0] != A[1]:
            B += 1
            A = A[1:]
        elif len(A)>3 and A[0] == A[1] and A[1] == A[2]:
            B += 2
            A = A[3:]
        elif len(A)<=3 and A[0] == A[1] and A[1] == A[2]:
            B += 1
            A = A[3:]
        elif len(A)==3 and A[-1] != A[-2] and A[-3] == A[-2]:
            B += 1
            A = A[3:]
        else:
            B += 2
            A = A[3:]
except IndexError:
    print(B)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

S = input()

Si = S[:1]
Si = ""

count = 1
i = 1
for j in range(2, len(S)+1):
    if Si == S[i:j]:
        pass
    else:
        Si = S[i:j]
        i = j
        count += 1
print(count)

Failing test case input:
aaa``a

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):

S = input()

Si = S[:1]

count = 1
i = 1
for j in range(2, len(S)+1):
    if Si == S[i:j]:
        pass
    else:
        Si = S[i:j]
        i = j
        count += 1
print(count)
Problem: p02939
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()

now = s[0]
cnt = 1
i = 1
while True:
    if s[i] != now:
        cnt += 1
        now = s[i]
        i += 1
    else:
        now = now + s[i]
        cnt += 1
        i += 2
        if i > len(s)-1:
            cnt -= 1
    if i >= len(s):
        break
print(cnt)

Failing test case input:
`^b``^

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
s = input()

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


now = s[0]
cnt = 1
i = 1
while True:
    if s[i] != now:
        cnt += 1
        now = s[i]
        i += 1
    else:
        now = now + s[i]
        cnt += 1
        i += 2
        if i > len(s):
            cnt -= 1
    if i >= len(s):
        break
print(cnt)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()

n = len(s)

adding = ""
added = ""

counter = 0

for i in range(n):
  adding += s[i]
  if s[i] != added:
    counter += 1
    added = adding
    adding = ""

print(counter)

Failing test case input:
abbbb`acbcababb

Expected output:
13


Actual output:
11


Fixed submission (verdict: Accepted):
s = input()
 
n = len(s)
 
adding = ""
added = ""
 
counter = 0
 
for i in range(n):
  adding += s[i]
  if adding != added:
    counter += 1
    added = adding
    adding = ""

    
print(counter)

Problem: p02939
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
s = input()

N = len(s)
a = []
a.append(s[0])

i = 1
j = 1
while i < N-1:
    pre = a[j-1]
    tmp = s[i]
    if pre == s[i]:
        tmp += s[i+1]
        i += 1
    a.append(tmp)
    i += 1
    j += 1
a.append(s[-1])

ans = len(a)
if a[-1] == a[-2]:
    ans -= 1
if a[-3] == a[-2]+a[-1]:
    ans -= 1
print(ans)

Failing test case input:
aaa``a

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
s = input()

N = len(s)
a = []
a.append(s[0])

i = 1
j = 1
while i < N-1:
    pre = a[j-1]
    tmp = s[i]
    if pre == s[i]:
        tmp += s[i+1]
        i += 1
    a.append(tmp)
    i += 1
    j += 1
a.append(s[-1])

ans = len(a)
if a[-1] == a[-2] or s != ''.join(map(str, a)):
    ans -= 1

print(ans)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
ans = 1
flag = 0

for i in range(1,len(s)):
    if flag == 1:
        flag = 0
        continue
    if s[i-1] == s[i]:
        flag = 1
    ans += 1
print(ans)


Failing test case input:
``aabadbc_bacb_

Expected output:
14


Actual output:
13


Fixed submission (verdict: Accepted):
s = input()
ans = 1
flag = 0
cut = 1

for i in range(1,len(s)):
    if flag == 1:
        flag = 0
        cut = 2
        ans += 1
        continue
    if s[i-1] == s[i] and cut == 1:
        flag = 1
        continue
    else:
        cut = 1
    ans += 1
print(ans)
Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
n = len(s)

bef = s[0]
key = 0
ans = 1
for i in range(1, n):
  if key == i:
    continue
  if bef == s[i]:
    if i == n-1:
      continue
    bef = s[i+1]
    ans += 1
    key = i+1
  else:
    bef = s[i]
    ans += 1
print(ans)

Failing test case input:
`bbac``abbaabbb

Expected output:
11


Actual output:
10


Fixed submission (verdict: Accepted):
s = input()
n = len(s)

bef = s[0]
key = 0
ans = 1
for i in range(1, n):
  if key == i:
    continue
  if bef == s[i]:
    if i == n-1:
      continue
    bef = s[i:i+2]
    ans += 1
    key = i+1
  else:
    bef = s[i]
    ans += 1
print(ans)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


s=input()

t=""

i=0

c=0

while(i<len(s)):
	if(s[i]!=t):
		c+=1
		t=s[i]
	i+=1

print(c+1)

Failing test case input:
`^b``^

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):


s=input()

t=""

i=0

c=0

while(i<len(s)):
	if(s[i]==t):
		i+=1
		if(i<len(s)):
			t+=s[i]
			c+=1
	else:
		t=s[i]
		c+=1
	i+=1

print(c)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

S = input()

Si = S[:1]
Si = ""

count = 1
i = 1
for j in range(2, len(S)):
    if Si == S[i:j]:
        pass
    else:
        Si = S[i:j]
        i = j
        count += 1
print(count)

Failing test case input:
b`aaa`

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):

S = input()

Si = S[:1]

count = 1
i = 1
for j in range(2, len(S)+1):
    if Si == S[i:j]:
        pass
    else:
        Si = S[i:j]
        i = j
        count += 1
print(count)

Problem: p02939
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
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 f:
    w.append(s[-1])
print(len(w))


Failing test case input:
bbbaacbaa`cbbb`

Expected output:
11


Actual output:
10


Fixed submission (verdict: Accepted):
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))
Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
lst = []
if len(s) == 1:
    print(1)
    exit()
q = 0
while q+1 <= len(s)-1:
    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:
    if s[-1] != lst[-1]:
        lst.append(s[-1])

cnt = 0
for i in range(len(lst)-1):
    if lst[i] != lst[i+1]:
        cnt += 1
else:
    if lst[i-1] != lst[i-2]:
        cnt += 1
print(cnt)

Failing test case input:
`^b``^

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
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)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input().rstrip()
n = len(s)
res = 1
prev = s[0]
index = 1
while index < n:
    c = s[index]
    res += 1
    if c != prev:
        index += 1
        prev = c
    else:
        index += 2
        prev = ''
        if index >= n:
            res -= 1
print(res)

Failing test case input:
`^b``^

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
s = input().rstrip()
n = len(s)
res = 1
prev = s[0]
index = 1
while index < n:
    c = s[index]
    res += 1
    if c != prev:
        index += 1
        prev = c
    else:
        index += 2
        prev = ''
        if index > n:
            res -= 1
print(res)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = list(input())
if len(s) == 1:
    print(1)
    exit()
elif len(s) == 2:
    if s[0] == s[1]:
        print(1)
    else:
        print(2)
    exit()
else:
    dp = [0]*len(s)
    if s[0]==s[1] and s[1]==s[2]:
        dp[0:3]=[1,2,2]
    elif s[0]==s[1] and s[1]!=s[2]:
        dp[0:3]=[1,1,2]
    elif s[0]!=s[1] and s[1]==s[2]:
        dp[0:3]=[1,2,2]
    else:
        dp[0:3]=[1,2,3]

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

print(dp[-1])

Failing test case input:
bbbaacbaa`cbbba

Expected output:
11


Actual output:
12


Fixed submission (verdict: Accepted):
s = list(input())
if len(s) == 1:
    print(1)
    exit()
elif len(s) == 2:
    if s[0] == s[1]:
        print(1)
    else:
        print(2)
    exit()
else:
    dp = [0]*len(s)
    if s[0]==s[1] and s[1]==s[2]:
        dp[0:3]=[1,1,2]
    elif s[0]==s[1] and s[1]!=s[2]:
        dp[0:3]=[1,1,2]
    elif s[0]!=s[1] and s[1]==s[2]:
        dp[0:3]=[1,2,2]
    else:
        dp[0:3]=[1,2,3]

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

print(dp[-1])
Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin

s = stdin.readline().rstrip()
N = len(s)

if N == 1:
    print(1)
    exit()
elif N == 2:
    if s[0] == s[1]:
        print(1)
        exit()
    else:
        print(2)
        exit()

dp = [0]*N
dp[0] = 1
dp[1] = 1
for i in range(2,N):
    if s[i] == s[i-1]:
        dp[i] = dp[i-3] + 2
    else:
        dp[i] = dp[i-1] + 1

print(dp[N-1])

Failing test case input:
`_b`ab`_babcdba

Expected output:
15


Actual output:
14


Fixed submission (verdict: Accepted):
from sys import stdin

s = stdin.readline().rstrip()
N = len(s)

if N == 1:
    print(1)
    exit()
elif N == 2:
    if s[0] == s[1]:
        print(1)
        exit()
    else:
        print(2)
        exit()

dp = [0]*N
dp[0] = 1
if s[0] == s[1]:
    dp[1] = 1
else:
    dp[1] = 2
for i in range(2,N):
    if s[i] == s[i-1]:
        dp[i] = dp[i-3] + 2
    else:
        dp[i] = dp[i-1] + 1

print(dp[N-1])

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()

dp = [[[0, ' '], [0, '  ']], [[1, s[1]], [1, ' '+s[1]]]]
for i in range(1, len(s)):
    if s[i-1:i+1] == dp[-2][1][1]:
        ndp1 = [dp[-2][0][0]+1, s[i-1:i+1]]
    else:
        ndp1 = [max(dp[-2][0][0], dp[-2][1][0])+1, s[i-1:i+1]]
    if s[i] == dp[-1][0][1]:
        ndp0 = [dp[-1][1][0]+1, s[i]]
    else:
        ndp0 = [max(dp[-1][0][0], dp[-1][1][0])+1, s[i]]
    dp.append([ndp0, ndp1])

print(max(dp[len(s)][0][0], dp[len(s)][1][0]))

Failing test case input:
aabbaa

Expected output:
4

Actual output:
5


Fixed submission (verdict: Accepted):
s = input()

dp = [[[0, ''], [0, '']], [[1, s[0]], [-10**6, '']]]
for i in range(1, len(s)):
    if s[i-1:i+1] == dp[-2][1][1]:
        ndp1 = [dp[-2][0][0]+1, s[i-1:i+1]]
    else:
        ndp1 = [max(dp[-2][0][0], dp[-2][1][0])+1, s[i-1:i+1]]
    if s[i] == dp[-1][0][1]:
        ndp0 = [dp[-1][1][0]+1, s[i]]
    else:
        ndp0 = [max(dp[-1][0][0], dp[-1][1][0])+1, s[i]]
    dp.append([ndp0, ndp1])

print(max(dp[len(s)][0][0], dp[len(s)][1][0]))

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)

Failing test case input:
``babaccc`bacb_

Expected output:
13


Actual output:
2 3 `b
3 4 a
4 5 b
5 6 a
6 7 c
7 9 cc
8 10 `
9 11 b
10 12 a
11 13 c
12 14 b
13 15 _
14 16 !
13


Fixed submission (verdict: Accepted):
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)
Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = list(input())
s = 0
num = 0
ans = 0
for i in range(len(S)):
    if i < num:
        continue
    for j in range(1,len(S)-i):
        if S[i:i+j] != s:
            s = S[i:i+j]
            num = i+j
            ans += 1
            break
print(ans+1)

Failing test case input:
b`abaa

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
S = list(input())
s = 0
num = 0
ans = 0
for i in range(len(S)):
    if i < num:
        continue
    for j in range(1,len(S)-i+1):
        if S[i:i+j] != s:
            s = S[i:i+j]
            num = i+j
            ans += 1
            break
print(ans)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=list(input())
l=len(s)
ans=0
moji=''
t=0
while t<=l-2:
    if s[t]==moji:
        moji=s[t]+s[t+1]
        t+=2
        ans+=1
    else:
        moji=s[t]
        t+=1
        ans+=1  

if s[-1]==moji:
    print(ans)
else:
    print(ans+1)




Failing test case input:
`_c``^

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
s=list(input())
l=len(s)
ans=0
moji=''
t=0
while t<=l-2:
    if s[t]==moji:
        moji=s[t]+s[t+1]
        t+=2
        ans+=1
    else:
        moji=s[t]
        t+=1
        ans+=1  

if t==l:
    print(ans)
elif s[-1]==moji:
    print(ans)
else:
    print(ans+1)

Problem: p02939
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def main():
    S = input()
    if S == 1:
        return 1
    dp_1 = [0] * len(S)
    dp_2 = [0] * len(S)
    if S[0] != S[1]:
        dp_1[0] = 1
        dp_1[1] = 2
    dp_2[1] = 1
    for i, v in enumerate(S):
        if i < 2:
            continue
        if v == S[i-1]:
            dp_1[i] = dp_2[i-1] + 1
        else:
            dp_1[i] = max(dp_1[i-1], dp_2[i-1]) + 1
        if i < 4 or S[i-1:i+1] == S[i-3:i-1]:
            dp_2[i] = dp_1[i-2] + 1
        else:
            dp_2[i] = max(dp_1[i-2], dp_2[i-2]) + 1
    return max(dp_1[-1], dp_2[-1])
print(main())


Failing test case input:
``aabadbc_bacb_

Expected output:
14


Actual output:
13


Fixed submission (verdict: Accepted):
def main():
    S = input()
    if S == 1:
        return 1
    dp_1 = [0] * len(S)
    dp_2 = [0] * len(S)
    if S[0] != S[1]:
        dp_1[1] = 2
    dp_1[0] = 1
    dp_2[1] = 1
    for i, v in enumerate(S):
        if i < 2:
            continue
        if v == S[i-1]:
            dp_1[i] = dp_2[i-1] + 1
        else:
            dp_1[i] = max(dp_1[i-1], dp_2[i-1]) + 1
        if i < 4 or S[i-1:i+1] == S[i-3:i-1]:
            dp_2[i] = dp_1[i-2] + 1
        else:
            dp_2[i] = max(dp_1[i-2], dp_2[i-2]) + 1
    return max(dp_1[-1], dp_2[-1])
print(main())