ZhenlongDai/ACPR huggingface dataset:
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 len(S)!=1:
    if S[-2]==S[-1] and tmp!=S[-2:]:
        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):
word = list(input())
p = 0
pre = word[0]
for i in range(len(word)):
  if len(pre) == 2:
    pre = "あ"
  else:
    if word[i] == pre and i == len(word) - 1:
      pass
    elif word[i] == pre:
      pre = word[i] + word[i + 1]
      p += 1
    else:
      pre = word[i]
      p += 1
print(p)
  

Failing test case input:
`_b`ab`_babcdba

Expected output:
15


Actual output:
14


Fixed submission (verdict: Accepted):
word = list(input())
p = 0
pre = "あ"
for i in range(len(word)):
  if len(pre) == 2:
    pre = "あ"
  else:
    if word[i] == pre and i == len(word) - 1:
      pass
    elif word[i] == pre:
      pre = word[i] + word[i + 1]
      p += 1
    else:
      pre = word[i]
      p += 1
print(p)

Problem: p02939
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def f(s):
    l=len(s)
    if l==1:
        return 1
    ret=l
    prev=s[0]
    for i in range(1,l-1):
        if s[i]==prev:
            ret-=1
            prev=s[i]+s[i+1]
        else:
            prev=s[i]
    if prev==s[-1]:
        ret-=1
    return ret

s=input()
ans=max(f(s),f(s[::-1]))
print(ans)

Failing test case input:
`bbac``abbaabbb

Expected output:
11


Actual output:
10


Fixed submission (verdict: Accepted):
def solve(s):
    l=len(s)
    S=[0]*(l+1)
    S[1]=1
    for i in range(1,l):
        if s[i]!=s[i-1]:
            S[i+1]=S[i]+1
        else:
            if i==1:
                S[i+1]=S[i]
            else:
                S[i+1]=S[i-2]+2
    return S[-1]

s=input()
print(solve(s))

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    word = input()
    answer = 1
    before = word[0]
    word = word[1:]
    while word != "":
        if word[0] == before and len(word) > 1:
            before = word[1]
            word = word[2:]
        else:
            before = word[0]
            word = word[1:]
        answer += 1
    print(answer)


if __name__ == '__main__':
    main()



Failing test case input:
aabccacabaababb

Expected output:
11


Actual output:
12


Fixed submission (verdict: Accepted):
def main():
    word = list(input())
    dp = [0] * len(word)
    dp[0] = 1
    dp[1] = 1
    if word[0] != word[1]:
        dp[1] = 2
    for i in range(2, len(word)):
        if word[i] != word[i - 1]:
            dp[i] = dp[i - 1] + 1
        else:
            dp[i] = dp[i - 3] + 2
    print(dp[len(word) - 1])


if __name__ == '__main__':
    main()
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
if s[0] == s[1]:
    dp[0] = 0
    dp[1] = 1
else:
    dp[0] = 1
    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])

Failing test case input:
^^``b`

Expected output:
5


Actual output:
4


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):
string = input()

before = ""
ans = 0
while len(string) > 1:
    if before == string[0]:
        temp = string[0:2]
        string = string[2:len(string)]
    else:
        temp = string[0]
        string = string[1:len(string)]
    before = temp
    ans += 1
if not before == string:
    ans += 1
print(ans)

Failing test case input:
`bbbc``abbaabbb

Expected output:
11


Actual output:
12


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

before = ""
before2 = ""
ans = 0
while len(string) > 1:
    if before == string[0]:
        temp = string[0:2]
        string = string[2:len(string)]
    else:
        temp = string[0]
        string = string[1:len(string)]
    before2 = before
    before = temp
    ans += 1
if not len(string) == 0 and not before == string and not before2 == before:
    ans += 1
print(ans)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
count = 0
start = 0
end = 1
hold_value = ""
while end <= len(S):
    if hold_value == S[start:end]:
        end += 1
    else:
        hold_value = S[start:end]
        print(hold_value)
        start = end
        end += 1
        count += 1
print(count)

Failing test case input:
bbbaacbaa`cbbb`

Expected output:
11


Actual output:
b
bb
a
ac
b
a
a`
c
b
bb
`
11


Fixed submission (verdict: Accepted):
S = input()
count = 0
start = 0
end = 1
hold_value = ""
while end <= len(S):
    if hold_value == S[start:end]:
        end += 1
    else:
        hold_value = S[start:end]
        
        start = end
        end += 1
        count += 1
print(count)
Problem: p02939
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()

now = s[0]
print(now)
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:
`_aa_a

Expected output:
5


Actual output:
`
5


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 (PyPy3 (2.4.0), verdict: Wrong Answer):
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)

Failing test case input:
bbbbacbca`bbbba

Expected output:
13


Actual output:
13 ['b', 'bb', 'b', 'a', 'c', 'b', 'c', 'a', '`', 'b', 'bb', 'b', 'a']


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

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S=input()
k=0
s=''
ex_s=''
pos=0

for i in range(len(S)):
  
  if pos > i:
    
    continue
  if pos >= len(S):
    break
    
  for j in range(1,len(S)-i+1):    
    s=S[i:i+j]    
    
    if ex_s==s:
      
      continue
    else:
      
      if   len(s)==2 and i+j+2==len(S):
        continue
      ex_s=s
      k += 1
      pos = i+j
      
      break;

print(k)
  

Failing test case input:
bbbbacbca`bbbba

Expected output:
13


Actual output:
12


Fixed submission (verdict: Accepted):
S=input()
k=0
s=''
ex_s=''
pos=0

for i in range(len(S)):
  
  if pos > i:
    
    continue
  if pos >= len(S):
    break
    
  for j in range(1,len(S)-i+1):    
    s=S[i:i+j]    
    
    if ex_s==s:
      
      continue
    else:
      
      if   len(s)==2 and i+j+2==len(S) and s==S[-2:]:
        continue
      ex_s=s
      k += 1
      pos = i+j
      
      break;

print(k)
Problem: p02939
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
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)


Failing test case input:
bbbaacbaa`cbbba

Expected output:
11


Actual output:
b, bb, a, ac, b, a, a`, c, b, bb, a

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

Failing test case input:
b`abaa

Expected output:
5


Actual output:
6


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

Problem: p02939
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S=list(str(input()))
temp=[]
ans=0
last=S[0]
for i in range(1,len(S)):
    temp.append(S[i])
    if temp!=last:
        last=temp
        temp=[]
        ans+=1
    
print(ans)


Failing test case input:
b`aa`a

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
S=list(str(input()))
temp=[]
ans=0
last=[]
for i in range(len(S)):
    temp.append(S[i])
    if temp!=last:
        last=temp
        temp=[]
        ans+=1

    
print(ans)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)
  
  if sb == False: 
    cnt += 1
    break
  cnt += 1
  if len(sb) == 0:
    break
print(cnt)

Failing test case input:
a``a``

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
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)
  
  if sb == False: 
    break
  cnt += 1
  if len(sb) == 0:
    break
print(cnt)
Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S=input()
k=0
s=''
ex_s=''
pos=0

for i in range(len(S)):
  if pos >= i:
    continue
  if pos > len(S):
    break
    
  for j in range(len(S)-i):    
    s=S[i:i+j+1]    
    if ex_s==s:
      continue
    else:
      ex_s=s
      k += 1
      pos = i+j
      break;

print(k)

Failing test case input:
^`^b``

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
S=input()
k=0
s=''
ex_s=''
pos=0

for i in range(len(S)):
  
  if pos > i:
    
    continue
  if pos >= len(S):
    break
    
  for j in range(1,len(S)-i+1):    
    s=S[i:i+j]    
    
    if ex_s==s:
      
      continue
    else:
      
      if   len(s)==2 and i+j+2==len(S) and s==S[-2:]:
        continue
      ex_s=s
      k += 1
      pos = i+j
      
      break;

print(k)

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

Failing test case input:
abbbc`aabcababb

Expected output:
12


Actual output:
13


Fixed submission (verdict: Accepted):
s = input()
ans = len(s)
f = 0
if len(s)==2 and len(set(s))==1:
  print(1)
  exit()

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

Problem: p02939
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = input()

last = ""
tmp = ""
ans = 0
for s in S:
    tmp += s
    if s == last:
        continue
    
    last = tmp
    tmp = ""
    ans += 1
print(ans)

Failing test case input:
``cbbaccc`babb_

Expected output:
11


Actual output:
10


Fixed submission (verdict: Accepted):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = input()

last = ""
tmp = ""
ans = 0
for s in S:
    tmp += s
    if tmp == last:
        continue
    
    last = tmp
    tmp = ""
    ans += 1
print(ans)
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()
b="-1"
ans=0
l=[]
while len(s)>1:
  if b!=s[:1]:
    b=s[:1]
    s=s[1:]
    ans+=1
  else:
    b=s[:2]
    s=s[2:]
    ans+=1
  l.append(b)
l.append(s)

for i in range(len(l)-1,-1,-1):
  if l[i]==l[i-1]:
    l[i-1]+=l[i]
    del l[i]

print(len(l))

Failing test case input:
abbbc`aabcababa

Expected output:
13


Actual output:
12


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()
c=0
s2=""
s3=""
for i in s:
 s3+=i
 if s2!=s3:
  c+=1
  s2+=s3
  s3=""
print(c)

Failing test case input:
a``a_`

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
s=input()
c=0
s2=""
s3=""
for i in s:
 s3+=i
 if s2!=s3:
  c+=1
  s2=s3
  s3=""
print(c)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S=input()
k=0
s=''
ex_s=''
pos=0

for i in range(len(S)):
  
  if pos > i:
    
    continue
  if pos > len(S):
    break
    
  for j in range(1,len(S)-i+1):    
    s=S[i:i+j]    
    
    if ex_s==s:
      
      continue
    else:
      
      if   len(s)==2 and i+j+2==len(S):
        continue
      ex_s=s
      k += 1
      pos = i+j
      
      break;

print(k)
  

Failing test case input:
bbbbacbca`bbbba

Expected output:
13


Actual output:
12


Fixed submission (verdict: Accepted):
S=input()
k=0
s=''
ex_s=''
pos=0

for i in range(len(S)):
  
  if pos > i:
    
    continue
  if pos >= len(S):
    break
    
  for j in range(1,len(S)-i+1):    
    s=S[i:i+j]    
    
    if ex_s==s:
      
      continue
    else:
      
      if   len(s)==2 and i+j+2==len(S) and s==S[-2:]:
        continue
      ex_s=s
      k += 1
      pos = i+j
      
      break;

print(k)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = str(input())
ans = 0
p = ''
q = ''
for s in S:
  p += s
  if p != q:
    ans += 1
    q = p
    p = ''
else:
  if len(p) > 0:
    ans += 1
print(ans)

Failing test case input:
aabccacabaababb

Expected output:
11


Actual output:
12


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

l = len(s)
ans = 1
tmp = s[0]
nxt = ""
for i in range(1,l):
    nxt += s[i]    
    if tmp == s[i]:
        continue
    else:
        ans += 1
        tmp = nxt
        nxt = ""

print(ans)

Failing test case input:
abbbcaaabaababc

Expected output:
12


Actual output:
10


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

l = len(s)
ans = 1
tmp = s[0]
nxt = ""
for i in range(1,l):
    nxt += s[i]    
    if tmp == nxt:
        continue
    else:
        ans += 1
        tmp = nxt
        nxt = ""

print(ans)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S=input()
k=0
s=''
ex_s=''
pos=0

for i in range(len(S)):
  if pos > i:
    continue
  if pos > len(S):
    break
    
  for j in range(len(S)-i):    
    s=S[i:i+j+1]    
    if ex_s==s:
      continue
    else:
      ex_s=s
      k += 1
      pos = i+j
      
      break;

print(k)
  

Failing test case input:
```b^^

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
S=input()
k=0
s=''
ex_s=''
pos=0

for i in range(len(S)):
  
  if pos > i:
    
    continue
  if pos >= len(S):
    break
    
  for j in range(1,len(S)-i+1):    
    s=S[i:i+j]    
    
    if ex_s==s:
      
      continue
    else:
      
      if   len(s)==2 and i+j+2==len(S) and s==S[-2:]:
        continue
      ex_s=s
      k += 1
      pos = i+j
      
      break;

print(k)

Problem: p02939
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = open(0).read().rstrip()
n = len(s)

ans = [0] * n
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-2]+1

print(ans[-1])

Failing test case input:
bbbbacbca`cbbba

Expected output:
13


Actual output:
12


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 (PyPy3 (2.4.0), verdict: Wrong Answer):
s=input()
n=len(s)
l=[]
l.append(s[0])
i=1
k=0
while i < n:
    j=1
    if i==n-1 and s[n-2]==s[n-1]:
        break
    while l[k] == s[i:i+j]:
        j += 1

    l.append(s[i:i+j])
    i += j
    k += 1


print(k+1)

Failing test case input:
abbbb`acbcabbbb

Expected output:
13


Actual output:
12


Fixed submission (verdict: Accepted):
s=input()
n=len(s)
l=[]
l.append(s[0])
i=1
k=0
while i < n:
    j=1

    if i==n-1 and l[k]==s[n-1]:
        break
    while l[k] == s[i:i+j]:
        j += 1

    l.append(s[i:i+j])
    i += j
    k += 1


print(k+1)
Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
ans = 0
p = ''
i = 0

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


Failing test case input:
aabccacabaababb

Expected output:
11


Actual output:
12


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

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
pr = s[0]
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 += 2
            else:
                break
        else:
            cnt += 1
            pr = s[i+1]
            i += 1
    else:
        cnt += 1
        pr = s[i+1]
        i += 1
print(cnt+1)

Failing test case input:
`bbac``abbaabbb

Expected output:
11


Actual output:
10


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 = [i for i in input()]
 
result = 1
i = 0
while i < len(s)-1:
  if s[i] == s[i+1]:
    i = i + 2
  else:
    i = i + 1
  result = result + 1
  if i > len(s):
    result = result - 1
    
print(result)

Failing test case input:
bbbaabbaa`cbbb`

Expected output:
11


Actual output:
10


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

Problem: p02939
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
a = [s[0]]
tmp = ""
cnt = 1

for i in range(1, len(s)):
    tmp = tmp + s[i]
    if s[-1] != tmp:
        a.append(tmp)
        tmp = ""
        cnt += 1
    else:
        continue
print(cnt)


Failing test case input:
aba``a

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
s = input()
a = [s[0]]
tmp = ""
cnt = 1

for i in range(1, len(s)):
    tmp = tmp + s[i]
    if a[-1] != tmp:
        a.append(tmp)
        tmp = ""
        cnt += 1
    else:
        continue
print(cnt)
Problem: p02939
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

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

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

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

S = input()

def g(i):
    if i == 0:
        return 0

    if i < 2:
        return 1

    if S[i] != S[i-1]:
        return g(i-1)+1

    return g(i-3)+2

print(g(len(S)-1))


Failing test case input:
a``aaa

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

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

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

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

S = input()
i = 1
r = len(S)
while True:
    if i >= len(S):
        break
    if S[i] == S[i-1]:
        r -= 1
        i += 2
    i += 1

print(r)

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

Failing test case input:
c`aaaa

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
s=input()
ans=0
b=""
a=""
for i in range(len(s)):
	a+=s[i]
	if b==a:
		continue
	else:
		ans+=1
		b=a
		a=""
print(ans)

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

dp=[0]*(n)
dp[0]=1
if n==1:
    print(1)
    exit()
if n==2:
    if s[0]==s[1]:
        print(1)
    else:
        print(2)
    exit()
if s[0]==s[1]:
    dp[1]=1
    dp[2]=2
if s[0]!=s[1]:
    if s[2]!=s[1]:
        dp[2]=3
    else:
        dp[2]=2
for i in range(3,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:
`^b``^

Expected output:
5


Actual output:
3


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

dp=[0]*(n)
dp[0]=1
if n==1:
    print(1)
    exit()
if n==2:
    if s[0]==s[1]:
        print(1)
    else:
        print(2)
    exit()
if s[0]==s[1]:
    dp[1]=1
    dp[2]=2
else:
    dp[1]=2
    if s[2]!=s[1]:
        dp[2]=3
    else:
        dp[2]=2
for i in range(3,n):
    if s[i]!=s[i-1]:
        dp[i]=dp[i-1]+1
    else:
        dp[i]=dp[i-3]+2
print(dp[n-1])
Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()

count = 1
sentence = S[0]
i=1

while i < len(S):
    print(sentence, S[i], count)
    if sentence != S[i]:
        sentence = S[i]
        count += 1
        i+=1
    elif i==len(S)-1:
        break
    else:
        count += 1
        sentence = S[i:i+2]
        i+=2

print(count)



Failing test case input:
abbbb`acbcababb

Expected output:
13


Actual output:
a b 1
b b 2
bb b 3
b ` 4
` a 5
a c 6
c b 7
b c 8
c a 9
a b 10
b a 11
a b 12
b b 13
13


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

count = 1
sentence = S[0]
i=1

while i < len(S):
    if sentence != S[i]:
        sentence = S[i]
        count += 1
        i+=1
    elif i==len(S)-1:
        break
    else:
        count += 1
        sentence = S[i:i+2]
        i+=2

print(count)

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


Failing test case input:
b`abaa

Expected output:
5


Actual output:
['b']
['`']
['a']
['b']
['a']
5


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

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

before = ""
before2 = ""
ans = 0
while len(string) > 1:
    if before == string[0]:
        temp = string[0:2]
        string = string[2:len(string)]
    else:
        temp = string[0]
        string = string[1:len(string)]
    before2 = before
    before = temp
    ans += 1
if not before == string and not before2 ==before:
    ans += 1
print(ans)

Failing test case input:
``cbbaccc`babb_

Expected output:
11


Actual output:
12


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

before = ""
before2 = ""
ans = 0
while len(string) > 1:
    if before == string[0]:
        temp = string[0:2]
        string = string[2:len(string)]
    else:
        temp = string[0]
        string = string[1:len(string)]
    before2 = before
    before = temp
    ans += 1
if not len(string) == 0 and not before == string and not before2 == before:
    ans += 1
print(ans)
Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
res = 1
i = 1
while i < len(s)-2:
  if s[i] == s[i-1]:
    i += 3
    res += 2
  else:
    res += 1
    i += 1
if i == len(s):
  print(res)
elif i == len(s)-1:
  if s[-1] == s[-2]:
    print(res)
  else:
    print(res+1)
elif i == len(s)-2:
  if s[-1] == s[-2]:
    print(res+1)
  else:
    if s[-1]==s[-3] or s[-1] == s[-2]:
      print(res+1)
    else:
      print(res+2)

Failing test case input:
b`c`baccc`babb_

Expected output:
13


Actual output:
14


Fixed submission (verdict: Accepted):
s = input()
res = 1
i = 1
while i < len(s)-2:
  if s[i] == s[i-1]:
    i += 3
    res += 2
  else:
    res += 1
    i += 1
if i == len(s):
  print(res)
elif i == len(s)-1:
  if s[-1] == s[-2]:
    print(res)
  else:
    print(res+1)
elif i == len(s)-2:
  if s[-1] == s[-2]:
    print(res+1)
  else:
    if s[-1]==s[-2] or s[-2] == s[-3]:
      print(res+1)
    else:
      print(res+2)

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


s = input()

ans = 0
pre = s[0]
i = 0
while i < len(s):
    cur = s[i]
    if pre == cur:
        pre = s[i] + s[i]
        i += 2
    else:
        pre = cur
        i += 1
    ans += 1
print(ans)


Failing test case input:
aaaccacabaababb

Expected output:
11


Actual output:
12


Fixed submission (verdict: Accepted):


s = input()

ans = 0
pre = ''
cur = ''
for i in range(len(s)):
    pre += s[i]
    if pre != cur:
        ans += 1
        cur = pre
        pre = ''
print(ans)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
A = tuple(S)
N = len(A)
ans = 1
ind = 1
pr = A[0:1]
while ind <= N - 3:
    if len(pr) == 2:
        pr = A[ind:ind + 1]
        ans += 1
        ind += 1
        continue
    if pr == A[ind:ind + 1]:
        pr = A[ind:ind + 2]
        ans += 1
        ind += 2
    else:
        pr = A[ind:ind + 1]
        ans += 1
        ind += 1
if N <= 2:

    if N == 1:
        ans = 1
    else:
        if A[0] == A[1]:
            ans = 1
        else:
            ans = 2
elif ind == N - 1:
    ans += 1

else:
    if pr == A[-2]:
        ans += 1
    elif A[-2] == A[-1]:
        ans += 1
    else:
        ans += 2
print(ans)

Failing test case input:
aaa``a

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
S = input()
A = tuple(S)
N = len(A)
ans = 1
ind = 1
pr = A[0:1]
while ind <= N - 3:
    if len(pr) == 2:
        pr = A[ind:ind + 1]
        ans += 1
        ind += 1
        continue
    if pr == A[ind:ind + 1]:
        pr = A[ind:ind + 2]
        ans += 1
        ind += 2
    else:
        pr = A[ind:ind + 1]
        ans += 1
        ind += 1
if N <= 2:

    if N == 1:
        ans = 1
    else:
        if A[0] == A[1]:
            ans = 1
        else:
            ans = 2
elif ind == N - 1:
    ans += 1

else:
    if pr == A[-2:] or pr == A[-2:-1]:
        ans += 1
    elif A[-2] == A[-1]:
        ans += 1
    else:
        ans += 2
print(ans)
Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()

n = len(s)

if n <= 2:
    print(n)
    exit()

g = [0] * n
g[0] = 1
if s[0] == s[1]:
    g[1] = 1
    g[2] = 2
elif s[1] == s[2]:
    g[1] = 2
    g[2] = 2

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

print(g[-1])

Failing test case input:
`_ca_`

Expected output:
6


Actual output:
3


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

n = len(s)

if n <= 2:
    print(n)
    exit()

g = [0] * n
g[0] = 1
if s[0] == s[1]:
    g[1] = 1
    g[2] = 2
elif s[1] == s[2]:
    g[1] = 2
    g[2] = 2
else:
    g[1] = 2
    g[2] = 3

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

print(g[-1])

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()
b="-1"
ans=0
while len(s)>1:
	if b!=s[:1]:
		b=s[:1]
		s=s[1:]
		ans+=1
	else:
		b=s[:2]
		s=s[2:]
		ans+=1
if b!=s:
	ans+=1

print(ans)

Failing test case input:
```aaa

Expected output:
4


Actual output:
5


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()
n=len(s)
ans=0
while s:
  if len(s)==n:
    si=s[0]
    s=s[1:]
  else:
    if si==s[0]:
      if len(s)==1:
        break
      else:
        si=s[:2]
        s=s[2:]
    else:
      si=s[0]
      s=s[1:]
print(ans)

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

Expected output:
13


Actual output:
0


Fixed submission (verdict: Accepted):
s=input()
n=len(s)
ans=0
while s:
  if len(s)==n:
    si=s[0]
    s=s[1:]
  else:
    if si==s[0]:
      if len(s)==1:
        break
      else:
        si=s[:2]
        s=s[2:]
    else:
      si=s[0]
      s=s[1:]
  ans+=1
print(ans)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    S = input()
    ans = 1
    cp = S[0]
    for c in S[1:]:
        if c != cp:
            ans += 1
            cp = c
        else:
            cp += c
    ans = ans + 1 if len(cp) == 2 else ans
    print(ans)


if __name__ == '__main__':
    main()


Failing test case input:
`bbbc`aabbaabbb

Expected output:
11


Actual output:
10


Fixed submission (verdict: Accepted):
def main():
    S = input()
    ans = 1
    cp, cn = S[0], ''
    for c in S[1:]:
        cn = cn + c
        if cp != cn:
            ans += 1
            cp = cn
            cn = ''
    print(ans)


if __name__ == '__main__':
    main()
Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
count = 1
i = 0
initial_length = len(S)-1
l = S[0]
S = S + '&' + '%'
print(S)
while i < initial_length:
    if l == S[i+1]:
        if i == initial_length-1:
            break
        elif S[i+2] == S[i+3]:
            l = S[i+3]
            i += 3
            count += 1
        else:
            l = S[i+1:i+3]
            i += 2
    else:
        l = S[i+1]
        i += 1
    count += 1
print(count)

Failing test case input:
`_aa_a

Expected output:
5


Actual output:
`_aa_a&%
5


Fixed submission (verdict: Accepted):
S = input()
count = 1
i = 0
initial_length = len(S)-1
l = S[0]
S = S + '&' + '%'
while i < initial_length:
    if l == S[i+1]:
        if i == initial_length-1:
            break
        elif S[i+2] == S[i+3]:
            l = S[i+3]
            i += 3
            count += 1
        else:
            l = S[i+1:i+3]
            i += 2
    else:
        l = S[i+1]
        i += 1
    count += 1
print(count)

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

ans = 1
pre = S[0]
c = 1
print(S[len(S)-1])
while 1:
    if c == len(S):
        break
    if c == len(S)-1:
        if S[c] == pre:
            break
        else:
            ans += 1
            break

    if S[c] == pre:
        pre = S[c]+S[c+1]
        ans += 1
        c += 2
    else:
        pre = S[c]
        ans += 1
        c += 1

print(ans)


Failing test case input:
`abab`ccbbb`c`b

Expected output:
13


Actual output:
b
13


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

ans = 1
pre = S[0]
c = 1
while 1:
    if c == len(S):
        break
    if c == len(S)-1:
        if S[c] == pre:
            break
        else:
            ans += 1
            break

    if S[c] == pre:
        pre = S[c]+S[c+1]
        ans += 1
        c += 2
    else:
        pre = S[c]
        ans += 1
        c += 1

print(ans)

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
if s[0] == s[1]:
    dp[0] = 0
    dp[1] = 1
else:
    dp[0] = 1
    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]+1)

Failing test case input:
```aaa

Expected output:
4


Actual output:
5


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

def main():
    S = input().rstrip()
    ans, cnt, cur = 0, 0, set()
    for i in S:
        cnt += 1
        cur |= {i}
        if cnt == 3:
            ans += max(2, len(cur))
            cnt, cur = 0, set()
    ans += len(cur)
    print(ans)


if __name__ == "__main__":
    main()

Failing test case input:
``babadbc_bacb_

Expected output:
14


Actual output:
13


Fixed submission (verdict: Accepted):

def main():
    S = input().rstrip()
    ans, prev, cur = 0, "", ""
    for s in S:
        cur += s
        if cur != prev:
            ans += 1
            prev, cur = cur, ""
    print(ans)


if __name__ == "__main__":
    main()

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

t = 0
last = ""
res = 0

while t < len(S):
    if S[t] == last:
        res += 1
        t += 2
    else:
        res += 1
        t += 1

print(res)

Failing test case input:
^^b```

Expected output:
4


Actual output:
6


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

res = 0
tmp = ""
last = ""

for s in S:
    tmp += s
    if tmp == last:
        continue

    last = tmp
    tmp = ""
    res += 1

print(res)

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

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


for i in range(1, len(s)):
    if num == 1:
        if s[i - 1] != s[i]:
            ans += 1
        else:
            num = 2
            ans += 1
    elif num == 2:
        num = 1
print(ans)

Failing test case input:
b`abaa

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
s = input()
ans = 1
num = 1 

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


for i in range(1, len(s)):
    if num == 1:
        if s[i - 1] != s[i]:
            ans += 1
        else:
            if i != len(s) - 1:
                num = 2
                ans += 1
    elif num == 2:
        num = 1.5
    elif num == 1.5:
        ans += 1
        num = 1
print(ans)

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

Failing test case input:
`^c``^

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
s = input()
res = 1
i = 1
while i < len(s)-2:
  if s[i] == s[i-1]:
    i += 3
    res += 2
  else:
    res += 1
    i += 1
if i == len(s):
  print(res)
elif i == len(s)-1:
  if s[-1] == s[-2]:
    print(res)
  else:
    print(res+1)
elif i == len(s)-2:
  if s[-1] == s[-2]:
    print(res+1)
  else:
    if s[-1]==s[-2] or s[-2] == s[-3]:
      print(res+1)
    else:
      print(res+2)
Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = str(input())

tmp= S[0]
now = ""
count = 0

for i in range(len(S)):
    now += S[i]
    if tmp != now:
        tmp = now
        now = ""
        count += 1

print(count)

Failing test case input:
_bcab`cccabab``

Expected output:
13


Actual output:
12


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

tmp= S[0]
now = ""
count = 1

for i in range(1, len(S)):
    now += S[i]
    if tmp != now:
        tmp = now
        now = ""
        count += 1

print(count)

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

Failing test case input:
_bcab_cbdabab``

Expected output:
14


Actual output:
15


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

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

Failing test case input:
a`acaa

Expected output:
5


Actual output:
6


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.8.2), verdict: Wrong Answer):
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

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

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

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

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

print(dp[-1])


Failing test case input:
`_`a`a

Expected output:
6


Actual output:
5


Fixed submission (verdict: Accepted):
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

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

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

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

S = input()
i = 1
r = len(S)
while True:
    if i >= len(S):
        break
    if S[i] == S[i-1]:
        r -= 1
        i += 2
    i += 1

print(r)

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

before = ""
ans = 0
while len(string) > 1:
    if before == string[0]:
        before = string[0:2]
        string = string[2:len(string)]
    else:
        before = string[0]
        string = string[1:len(string)]
    print(before)
    ans += 1
if not before == string:
    ans += 1
print(ans)

Failing test case input:
`_`c_`

Expected output:
6


Actual output:
`
_
`
c
_
6


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

before = ""
before2 = ""
ans = 0
while len(string) > 1:
    if before == string[0]:
        temp = string[0:2]
        string = string[2:len(string)]
    else:
        temp = string[0]
        string = string[1:len(string)]
    before2 = before
    before = temp
    ans += 1
if not len(string) == 0 and not before == string and not before2 == before:
    ans += 1
print(ans)

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

Failing test case input:
`^b``^

Expected output:
5


Actual output:
6


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()
i = 1
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))

Failing test case input:
abbbb`acbcabbbb

Expected output:
13


Actual output:
12


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

print(p + 1)

Failing test case input:
a`a`_`

Expected output:
6


Actual output:
5


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 (Python (3.4.3), verdict: Wrong Answer):
S = input()
idx = 1
count = 0
S_b = S[0]

while True:
    if idx == len(S)-1:
        break
    S_a = S[idx]
    if S_a == S_b:
        count += 1
        S_b = S[idx:idx+2]
    else:
        S_b = S_a
    idx += 1
print(len(S)-count)

Failing test case input:
``aa_`

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
S = input()
idx = 1
count = 0
S_b = S[0]

while True:
    if idx >= len(S):
        break
    S_a = S[idx]
    if S_a == S_b:
        count += 1
        S_b = S[idx:idx+2]
        idx += 2
    else:
        S_b = S_a
        idx += 1
print(len(S)-count)

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

Failing test case input:
aaa``b

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
s = input()
res = 1
i = 1
while i < len(s)-2:
  if s[i] == s[i-1]:
    i += 3
    res += 2
  else:
    res += 1
    i += 1
if i == len(s):
  print(res)
elif i == len(s)-1:
  if s[-1] == s[-2]:
    print(res)
  else:
    print(res+1)
elif i == len(s)-2:
  if s[-1] == s[-2]:
    print(res+1)
  else:
    if s[-1]==s[-2] or s[-2] == s[-3]:
      print(res+1)
    else:
      print(res+2)