Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
s = input()

subsg = []
subsp = []

sg = 0
sp = 0
ans = 0
for i in range(N):
    if s[i] == 'g':
        sg += 1
    else:
        sp += 1
    subsg.append(sg)
    subsp.append(sp)

for i in range(N):
    if subsp <= subsg:
        ans += 1
    
print(ans)

Fixed submission:
s = input()

sg = 0
sp = 0
ans = 0

for i in range(len(s)):
    if sp+1 <= sg and s[i] == 'g':
        sp += 1
        ans += 1
    elif sp+1 > sg and s[i] == 'p':
        sg += 1
        ans -= 1
    elif sp+1 <= sg and s[i] == 'p':
        sp += 1
    else:
        sg += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):

def main():

    A,B = map(int,input().split())
    if A==0 or B==0:
        print("IMPOSSIBLE")
        exit()
    if A%2!=B%2:
        print("IMPOSSIBLE")
        exit()


    K=0
    tmp =A
    A 
    while(True):

        if abs(A-K)==abs(B-K):
            print(K)
            exit()
        K += 1



if __name__== "__main__":
    main() 


Fixed submission:

def main():

    A,B = map(int,input().split())
    if A==0 or B==0:
        print("IMPOSSIBLE")
        exit()
    if A%2!=B%2:
        print("IMPOSSIBLE")
        exit()

    small = min(A,B)
    large = max(A,B)
    large -= small
    print(int(large/2+small))




if __name__== "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():

    N,M=map(int,input().split())
    #undivList=[map(int,(input().split())) for _ in range(N)]
    undivList=[]
    for _ in range(M):
        l=map(int,input().split())
        undivList +=l
    atmax=max(undivList[0::2])
    atmin=min(undivList[1::2])
    
    if atmax-atmin < 0:
		print(0)
    else:
		print(abs(atmax-atmin)+1)

    


if __name__== "__main__":
    main() 

Fixed submission:
def main():

    N,M=map(int,input().split())
    #undivList=[map(int,(input().split())) for _ in range(N)]
    undivList=[]
    for _ in range(M):
        l=map(int,input().split())
        undivList +=l
    atmax=max(undivList[0::2])
    atmin=min(undivList[1::2])
    
    if atmax>atmin:
        print(0)
    else:
        print(abs(atmax-atmin)+1)



if __name__== "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def main():

    N,X= map(int,input().split())
    targetList = list(map(int,input().split()))
    targetList.append(X)
    targetList.sort()
    diffList = []

    if N !=1:

        for i in range(N-1):
            diffList.append(targetList[i+1] - targetList[i])
    else:
        print(abs(targetList[0]-targetList[1]))
        exit()


    print(reduce(math.gcd,diffList))

        
    
if __name__== "__main__":
    main() 


Fixed submission:
import fractions
from functools import reduce

def main():

    N,X= map(int,input().split())
    targetList = list(map(int,input().split()))
    targetList.append(X)
    targetList.sort()
    diffList = []

    if N > 2:
        for i in range(N-1):
            diffList.append(targetList[i+1] - targetList[i])

    elif N==2:
        for i in targetList:
            diffList.append(i)
    else:
        print(abs(targetList[0]-targetList[1]))
        exit()

    print(reduce(fractions.gcd,diffList))

        
    
if __name__== "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from collections import Counter

def main():

    S = list(input())
    head = S.pop(0)
    cList = []
    flag  = False
    flag1 = False
    flag2 = False

    if head == 'A':
        flag = True
    
    for i,j in enumerate(S[1:-2]):
        if j=='C':
            cList=S.pop(i+1)
    if len(cList)==1:
        flag1=True
    
    if ''.join(S).islower():
        flag2 = True
    
    if flag and flag1 and flag2:
        print('AC')
    else:
        print('WA')


    
if __name__== "__main__":
    main() 











Fixed submission:
from collections import Counter

def main():

    S = list(input())
    head = S.pop(0)
    cList = []
    flag  = False
    flag1 = False
    flag2 = False

    if head == 'A':
        flag = True
    
    for i,j in enumerate(S[1:-1]):
        if j=='C':
            cList.append(i+1)
    if len(cList)==1:
        flag1=True
        S.pop(cList[0])
        
    if ''.join(S).islower():
        flag2 = True
    
    if flag and flag1 and flag2:
        print('AC')
    else:
        print('WA')


    
if __name__== "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
from collections import Counter

def main():

    S = list(input())
    head = S.pop(0)
    cList = []
    flag  = False
    flag1 = False
    flag2 = False

    if head == 'A':
        flag = True
    
    for i,j in enumerate(S[1:-2]):
        if j=='C':
            cList=S.pop(i)
    if len(cList)==1:
        flag1=True
    
    if ''.join(S).islower():
        flag2 = True
    
    if flag and flag1 and flag2:
        print('AC')
    else:
        print('WA')


    
if __name__== "__main__":
    main() 











Fixed submission:
from collections import Counter

def main():

    S = list(input())
    head = S.pop(0)
    cList = []
    flag  = False
    flag1 = False
    flag2 = False

    if head == 'A':
        flag = True
    
    for i,j in enumerate(S[1:-1]):
        if j=='C':
            cList.append(i+1)
    if len(cList)==1:
        flag1=True
        S.pop(cList[0])
        
    if ''.join(S).islower():
        flag2 = True
    
    if flag and flag1 and flag2:
        print('AC')
    else:
        print('WA')


    
if __name__== "__main__":
    main()
Buggy python submission (verdict: Runtime Error):

def main():

    if sum(list(map(int,list(input())))) !=1:
        print(sum(list(map(int,list(input())))))
    else:
        print(10)
 

    
if __name__== "__main__":
    main() 











Fixed submission:

def main():
    ans = sum(list(map(int,list(input()))))
    if  ans!=1:
        print(ans)
    else:
        print(10)
 

    
if __name__== "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):


def main():


   N = int(input())
   seList = input()
   ans = len(seList)
   tmp = ans

   for i in range(N):
      tmp = seList[:i].count('W')+seList[i:].count('E')
      if tmp < ans:
         ans = tmp
   print(ans)







if __name__== "__main__":
    main() 



Fixed submission:


def main():

   N = int(input())
   seList = input()
   a_seList = []
   ans = len(seList)-1
   reW = seList.count('W')
   reE = seList.count('E')
   if seList[0] == 'W':
      reW -= 1
      a_seList.append(1+reE-reW)
   else:
      reE -= 1
      a_seList.append(-1+reE-reW)
   
   for k,i in enumerate(seList[1:]):
      if i=='W':
         reW -= 1
         a_seList.append(a_seList[k]+1)
      else :
         reE -= 1
         a_seList.append(a_seList[k]-1)
         
   
   leader = a_seList.index(min(a_seList))         
   ans=seList[:leader].count('W')+seList[leader+1:].count('E')
   print(ans)








if __name__== "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
a＝input()
b＝input()
c＝input()
print(a[0]+b[1]+c[2])


Fixed submission:

a=input()
b=input()
c=input()
print(a[0]+b[1]+c[2])

Buggy python submission (verdict: Runtime Error):
a＝input()
b＝input()
c＝inpit()
print(a[0]+b[1]+c[2])

Fixed submission:

a=input()
b=input()
c=input()
print(a[0]+b[1]+c[2])
Buggy python submission (verdict: Runtime Error):
a=input()
b=input'()
print('YES' if a[-1::-1]==b else 'NO')

Fixed submission:
a=input()
b=input()
print('YES' if a[-1::-1]==b else 'NO')
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = int(input())
print(N*N-a)

Fixed submission:
N = int(input())
A = int(input())
print(N*N-A)
Buggy python submission (verdict: Runtime Error):
print('Possible' if int(input())%3==0 else 'Impossible')

Fixed submission:
a,b=map(int,input().split())
print( 'Possible' if a%3==0 or b%3==0 or (a+b)%3==0  else 'Impossible')
Buggy python submission (verdict: Runtime Error):
from collections import deque
n, m = map(int, input().split())

adj_list = [[] for i in range(n)]

for i in range(m):
  _, __ = map(int, input().split())
  _ -= 1
  __ -= 1
  adj_list[_].append(__)
  adj_list[__].append(_)
  
distance = [None for i in range(n)]
updated_from = [None for i in range(n)]

newly_visited = deque([0])
distance[0] = 0

while len(newly_visited) > 0:
  now = newly_visited.popleft()
  for i in adj_list[now]:
    if distance[i] is not None: continue
    newly_visited.append(i)
    distance[i] = distance[now] + 1
    updated_from[i] = now

# i に到達できてれば distance[i] ==（0 から i までの距離）
# i に到達できてなければ distance[i] == None   
    
"""
print(distance)

for i in range(n):
  # i から 0 に行く経路を求める
  now = i
  path = [now]
  while now != 0:
    now = updated_from[now]
    path.append(now)
  print(i, path) 
"""

print("Yes")
for i in range(n):
  print(updated_from[i] + 1)




Fixed submission:
from collections import deque
n, m = map(int, input().split())

adj_list = [[] for i in range(n)]

for i in range(m):
  _, __ = map(int, input().split())
  _ -= 1
  __ -= 1
  adj_list[_].append(__)
  adj_list[__].append(_)
  
distance = [None for i in range(n)]
updated_from = [None for i in range(n)]

newly_visited = deque([0])
distance[0] = 0

while len(newly_visited) > 0:
  now = newly_visited.popleft()
  for i in adj_list[now]:
    if distance[i] is not None: continue
    newly_visited.append(i)
    distance[i] = distance[now] + 1
    updated_from[i] = now

# i に到達できてれば distance[i] ==（0 から i までの距離）
# i に到達できてなければ distance[i] == None   
    
"""
print(distance)

for i in range(n):
  # i から 0 に行く経路を求める
  now = i
  path = [now]
  while now != 0:
    now = updated_from[now]
    path.append(now)
  print(i, path) 
"""

print("Yes")
for i in range(1, n):
  print(updated_from[i] + 1)
Buggy python submission (verdict: Runtime Error):
n, m, k = map(int, input().split())

f_adj_list = [[] for i in range(n)]
b_adj_list = [[] for i in range(n)]

for i in range(m):
  _, __ = map(int, input().split())
  _ -= 1
  __ -= 1
  f_adj_list[_].append(__)
  f_adj_list[__].append(_)
  
for j in range(k):
  _, __ = map(int, input().split())
  _ -= 1
  __ -= 1
  b_adj_list[_].append(__)
  b_adj_list[__].append(_)
  
  
group_id = [None for i in range(n)]
for i in range(n):
  # i から DFS
  newly_visited = [i]
  group_id[i] = i
  while len(newly_visited) > 0:
    now = newly_visited.pop()
    for j in f_adj_list[now]:
      if group_id[j] is not None: continue
      newly_visited.append(j)
      group_id[j] = i

# group_id
# print(group_id)

# 連結成分のサイズ
from collections import Counter
cnt = Counter(group_id)
# cnt[5] = 7

ans_list = []
for i in range(n):
  ans = cnt[group_id[i]]
  ans -= 1 # 自分自身
  ans -= len(f_adj_list[i]) # 直接の友達
  for j in b_adj_list[i]:
    if group_id[i] == group_id[j]:
      ans -= 1
  ans_list.append(ans)

print(" ".join(ans_list))


Fixed submission:
n, m, k = map(int, input().split())

f_adj_list = [[] for i in range(n)]
b_adj_list = [[] for i in range(n)]

for i in range(m):
  _, __ = map(int, input().split())
  _ -= 1
  __ -= 1
  f_adj_list[_].append(__)
  f_adj_list[__].append(_)
  
for j in range(k):
  _, __ = map(int, input().split())
  _ -= 1
  __ -= 1
  b_adj_list[_].append(__)
  b_adj_list[__].append(_)
  
  
group_id = [None for i in range(n)]
for i in range(n):
  if group_id[i] is not None: continue
  # i から DFS
  newly_visited = [i]
  group_id[i] = i
  while len(newly_visited) > 0:
    now = newly_visited.pop()
    for j in f_adj_list[now]:
      if group_id[j] is not None: continue
      newly_visited.append(j)
      group_id[j] = i

# group_id
# print(group_id)

# 連結成分のサイズ
from collections import Counter
cnt = Counter(group_id)
# cnt[5] = 7

ans_list = []
for i in range(n):
  ans = cnt[group_id[i]]
  ans -= 1 # 自分自身
  ans -= len(f_adj_list[i]) # 直接の友達
  for j in b_adj_list[i]:
    if group_id[i] == group_id[j]:
      ans -= 1
  ans_list.append(ans)

print(" ".join(map(str, ans_list)))
Buggy python submission (verdict: Runtime Error):
k, x = map(int, input().split())
print(' '.join(list(range(x-k+1, x+k))))

Fixed submission:
k, x = map(int, input().split())
print(' '.join(map(str, list(range(x-k+1, x+k)))))
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,[input() for i in range(3)])
print('Hello World' if n==1 else a+b)

Fixed submission:
n=int(input())
if n==1:
  print('Hello World')
else:
  a=int(input());b=int(input())
  print(a+b)

Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
print('Hello World' if n==1 else a+b)

Fixed submission:
n=int(input())
if n==1:
  print('Hello World')
else:
  a=int(input());b=int(input())
  print(a+b)
Buggy python submission (verdict: Runtime Error):
n,m,x,y=map(int,input().split());x=max(list(map(int,input.split()))+[x]);y=min(list(map(int,input.split()))+[y]);print('No War'if x<y else'War')

Fixed submission:
n,m,x,y=map(int,input().split());x=max(list(map(int,input().split()))+[x]);y=min(list(map(int,input().split()))+[y]);print('No War'if x<y else'War')
Buggy python submission (verdict: Runtime Error):
x = map(int, input().split())
print(max(x) - min(x))

Fixed submission:
x = list(map(int, input().split()))
print(max(x) - min(x))

Buggy python submission (verdict: Runtime Error):
a=list(map(int,split(input())))
print(max(a)-min(a))

Fixed submission:
x = list(map(int, input().split()))
print(max(x) - min(x))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n+1):
  if i==0 or i==n & a[i-1] != a[i]:
    if i!=0:
      ans += cnt // 2
    cnt = 1
  else:
    cnt += 1
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n+1):
  if i==0 or i==n or a[i-1] != a[i]:
    if i!=0:
      ans += cnt // 2
    cnt = 1
  else:
    cnt += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
c=[0]*114514;input();for i in map(int,input().split()):;    c[i]+=1;print(max([sum(c[i:i+3]) for i in range(100000)]))

Fixed submission:
import numpy as np;c=[0]*10**5;input()
for i in map(int,input().split()):
    c[i]+=1
print(max([sum(c[i:i+3]) for i in range(10**5)]))
Buggy python submission (verdict: Runtime Error):
p=map(int,input().split());print('Yes'if p[0]<=p[2]<=p[1]else'No')

Fixed submission:
p=list(map(int,input().split()));print('Yes' if p[0]<=p[2]<=p[1] else 'No')

Buggy python submission (verdict: Runtime Error):
p=map(int,input().split());print('Yes'if p[0<=p[2]<=p[1]else'No')

Fixed submission:
p=list(map(int,input().split()));print('Yes' if p[0]<=p[2]<=p[1] else 'No')
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
if a==b: print('EQUAL')
elif a>b: print('GREATER')
else: print('LESS')

Fixed submission:
print(''.join([chr(ord(i[0])+ord('A')-ord('a')) for i in input().split()]))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
hs = list(map(int, input().split()))

dp = [float("inf") in range(n)]

for i in range(1, n):
    for j in range(min(i, k)):
        dp[i] = min(dp[i], dp[j] + abs(hs[j] - hs[i]))

print(dp[i])

Fixed submission:
n, k = map(int, input().split())
hs = list(map(int, input().split()))

dp = [0] + [float("inf") for _ in range(n - 1)]

for i in range(1, n):
    for j in range(1, min(i, k) + 1):
        dp[i] = min(dp[i], dp[i - j] + abs(hs[i - j] - hs[i]))
print(dp[i])

Buggy python submission (verdict: Time Limit Exceeded):
n, k = tuple(map(int, input().split()))
hs = list(map(int, input().split()))
cs = [0 for _ in range(k)]
k_i = 0
for i in range(1, n):
    if i < k:
        cs[i] = min([cs[j] + abs(hs[j] - hs[i]) for j in range(i)])
    else:
        k_i = i % k
        cs[k_i] = min([
            cs[(k_i - j - 1) % k] + abs(hs[i - j - 1] - hs[i])
            for j in range(k)
        ])
print(cs[i % k])


Fixed submission:
n, k = map(int, input().split())
hs = list(map(int, input().split()))

dp = [0] + [float("inf") for _ in range(n - 1)]

for i in range(1, n):
    for j in range(1, min(i, k) + 1):
        dp[i] = min(dp[i], dp[i - j] + abs(hs[i - j] - hs[i]))
print(dp[i])
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
AB = []
ans = [-1] * (n) #####

edge = [[] for _ in range(n)] #edge[i] := 頂点iから伸びてる辺の行き先のリスト #####

for i in range(m):
    a,b = map(int,input().split())
    edge[a].append(b)    
    edge[b].append(a)    
    
import collections
que = collections.deque()
que.append(0) #####
    
while que:
    x = que.popleft()
    
    for to in edge[x]:
        a = x
        b = to
        
        if ans[b] == -1: #####
            ans[b] = x + 1 #####
            que.append(b)
            
print("Yes")
print(*ans,sep="\n")


Fixed submission:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M=MI()
    edge = [[] for _ in range(N)]
    for i in range(M):
        a,b = MI_()
        edge[a].append(b)
        edge[b].append(a)
    queue = deque([0])
    dist = [inf]*N
    dist[0] = 0
    ans = [-1]*N
    while(queue):
        v = queue.popleft()
        for to in edge[v]:
            if(dist[to]==inf):
                ans[to] = v+1
                queue.append(to)
                dist[to] = dist[v] + 1

    print("Yes")
    print(*ans[1:],sep="\n")

    
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    H, N = MI()
    AB = LLIN(N)

    dp = [inf]*(H+1)
    dp[0] = 0
    for a,b in AB:
        for h in range(H+1):
            if h>=a:
                dp[h] = min(dp[h], dp[h-a] + b)
            else:
                dp[h] = min(dp[h], b)

    print(dp[H])
if __name__ == '__main__':
    main()

Fixed submission:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    H, N = MI()
    AB = LLIN(N)

    dp = [inf]*(H+1)
    dp[0] = 0
    for a,b in AB:
        for h in range(H+1):
            if h>=a:
                dp[h] = min(dp[h], dp[h-a] + b)
            else:
                dp[h] = min(dp[h], b)

    print(dp[H])
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n=int(input())
for i in range(1,10):
  for j in range(1,10):
    if n==i*j:
      print("Yes")
	  exit()
print("No")

Fixed submission:
n=int(input())
for i in range(1,10):
    for j in range(1,10):
        if n==i*j:
            print("Yes")
            exit()
print("No")
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    S = input()
    N = len(S)
    from collections import deque

    def solve(S):
        cur = S[0]
        ans1 = 1
        i = 1
        plus = 1
        while i < N:
            if S[i:i+plus] == cur:
                plus += 1
            else:
                cur=S[i:i+plus]
                i = i+plus
                plus = 1
                ans1 += 1

        cur = S[:2]
        ans2 = 1
        i = 2
        plus = 1
        while i < N:
            if S[i:i+plus] == cur:
                plus += 1
            else:
                cur = S[i:i+plus]
                i = i+plus
                plus = 1
                ans2 += 1
        return ans1, ans2
    ans1, ans2 = solve(S)
    ans3, ans4 = solve(S[::-1])
    print(max(ans1, ans2, ans3, ans4))


if __name__ == '__main__':
    main()


Fixed submission:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S=ST()
    before = ""
    before_index = 0
    N=len(S)
    i=0
    ans=0
    while i < N:
        if before != S[before_index:i+1]:
            # print(S[before_index:i+1], before)
            ans+=1
            before=S[before_index:i+1]
            before_index=i+1
        i+=1
    print(ans)
if __name__ == '__main__':
    main()