Buggy python submission (verdict: Runtime Error):
# 再帰関数
# 入力文字列の最大の正整数を返す
# def func( in_str: str, prev: str ):
#     if len(in_str) == 0:
#         return 0
#     for i in range(len(in_str)):
#         s = in_str[0:i+1]
#         if s == prev:
#             continue
#         else:
#             new_str = in_str[i+1:]
#             ret = func(new_str, s)
#             if ret == -1:
#                 continue
#             return 1 + ret
#
#     return -1

#再帰じゃない
def func( in_str: str ):
    prev =""
    num_in_str = len(in_str)
    new_str = in_str
    stack_str =[]
    stack_start = []
    stack_i = []
    stack_K = []
    K = 0
    old_i = 0
    is_separate = False
    while(True):
        num = len(new_str)
        if num == 0:
            break
        for i in range(old_i, num):
            s = new_str[0:i+1]
            if s == prev:
                is_separate = False
                continue
            else:
                # 分岐前に状態保存
                stack_str.append(new_str)
                stack_start.append(num_in_str - len(new_str))
                stack_i.append(i+1)
                stack_K.append(K)

                new_str = new_str[i+1:]

                prev = s
                K += 1
                is_separate = True
                break
        # 失敗したらスタックからもとに戻す
        if is_separate == False:
            new_str = stack_str.pop()
            start = stack_start.pop()
            new_str = in_str[start:]
            old_i = stack_i.pop()
            K = stack_K.pop()
        else:
            old_i = 0

    return K

s = input()
#s="aaaccacabaababc"
#s="aaaccacabaldkfjadhjdhafidhkajhdkfjahdskjhfakhdkfaababc"*1000
#num = func( s, "")
num = func( s )

print(num)

Fixed submission:
# 再帰関数
# 入力文字列の最大の正整数を返す
# def func( in_str: str, prev: str ):
#     if len(in_str) == 0:
#         return 0
#     for i in range(len(in_str)):
#         s = in_str[0:i+1]
#         if s == prev:
#             continue
#         else:
#             new_str = in_str[i+1:]
#             ret = func(new_str, s)
#             if ret == -1:
#                 continue
#             return 1 + ret
#
#     return -1

#再帰じゃない
def func( in_str: str ):
    prev =""
    num_in_str = len(in_str)
    new_str = in_str
    stack_str =[]
    stack_start = []
    stack_i = []
    stack_K = []
    K = 0
    old_i = 0
    is_separate = False
    while(True):
        num = len(new_str)
        if num == 0:
            break
        for i in range(old_i, num):
            s = new_str[0:i+1]
            if s == prev:
                is_separate = False
                continue
            else:
                # 分岐前に状態保存
                #stack_str.append(new_str)
                stack_start.append(num_in_str - len(new_str))
                stack_i.append(i+1)
                stack_K.append(K)

                new_str = new_str[i+1:]

                prev = s
                K += 1
                is_separate = True
                break
        # 失敗したらスタックからもとに戻す
        if is_separate == False:
            #new_str = stack_str.pop()
            start = stack_start.pop()
            new_str = in_str[start:]
            old_i = stack_i.pop()
            K = stack_K.pop()
        else:
            old_i = 0

    return K

s = input()
#s="aabbaa"
#s="aaaccacabaldkfjadhjdhafidhkajhdkfjahdskjhfakhdkfaababc"*1000
#num = func( s, "")
num = func( s )

print(num)

Buggy python submission (verdict: Runtime Error):
# 再帰関数
# 入力文字列の最大の正整数を返す
# def func( in_str: str, prev: str ):
#     if len(in_str) == 0:
#         return 0
#     for i in range(len(in_str)):
#         s = in_str[0:i+1]
#         if s == prev:
#             continue
#         else:
#             new_str = in_str[i+1:]
#             ret = func(new_str, s)
#             if ret == -1:
#                 continue
#             return 1 + ret
#
#     return -1

#再帰じゃない
def func( in_str: str ):
    result = 0
    prev =""
    new_str = in_str
    stack_str =[]
    stack_i = []
    stack_K = []
    K = 0
    old_i = 0
    is_separate = False
    while(True):
        num = len(new_str)
        if num == 0:
            break
        for i in range(old_i, num):
            s = new_str[0:i+1]
            if s == prev:
                is_separate = False
                continue
            else:
                # 分岐前に状態保存
                stack_str.append(new_str)
                stack_i.append(i+1)
                stack_K.append(K)

                new_str = new_str[i+1:]
                prev = s
                K += 1
                is_separate = True
                break;
        # 失敗したらスタックからもとに戻す
        if is_separate == False:
            new_str = stack_str.pop()
            old_i = stack_i.pop()
            K = stack_K.pop()
        else:
            old_i = 0

    return K

s = input()
#s="aabbaa"
#s="aaaccacabaldkfjadhjdhafidhkajhdkfjahdskjhfakhdkfaababc"*1000
#num = func( s, "")
num = func( s )

print(num)

Fixed submission:
# 再帰関数
# 入力文字列の最大の正整数を返す
# def func( in_str: str, prev: str ):
#     if len(in_str) == 0:
#         return 0
#     for i in range(len(in_str)):
#         s = in_str[0:i+1]
#         if s == prev:
#             continue
#         else:
#             new_str = in_str[i+1:]
#             ret = func(new_str, s)
#             if ret == -1:
#                 continue
#             return 1 + ret
#
#     return -1

#再帰じゃない
def func( in_str: str ):
    prev =""
    num_in_str = len(in_str)
    new_str = in_str
    stack_str =[]
    stack_start = []
    stack_i = []
    stack_K = []
    K = 0
    old_i = 0
    is_separate = False
    while(True):
        num = len(new_str)
        if num == 0:
            break
        for i in range(old_i, num):
            s = new_str[0:i+1]
            if s == prev:
                is_separate = False
                continue
            else:
                # 分岐前に状態保存
                #stack_str.append(new_str)
                stack_start.append(num_in_str - len(new_str))
                stack_i.append(i+1)
                stack_K.append(K)

                new_str = new_str[i+1:]

                prev = s
                K += 1
                is_separate = True
                break
        # 失敗したらスタックからもとに戻す
        if is_separate == False:
            #new_str = stack_str.pop()
            start = stack_start.pop()
            new_str = in_str[start:]
            old_i = stack_i.pop()
            K = stack_K.pop()
        else:
            old_i = 0

    return K

s = input()
#s="aabbaa"
#s="aaaccacabaldkfjadhjdhafidhkajhdkfjahdskjhfakhdkfaababc"*1000
#num = func( s, "")
num = func( s )

print(num)

Buggy python submission (verdict: Runtime Error):

# 再帰関数
# 入力文字列の最大の正整数を返す
def func( in_str: str, prev: str ):
    if len(in_str) == 0:
        return 0
    num = 0
    new_str = ""
    for i in range(len(in_str)):
        s = in_str[0:i+1]
        if s == prev:
            continue
        else:
            new_str = in_str[i+1:]
            ret = func(new_str, s)
            if ret == -1:
                continue
            return 1 + ret

    return -1


s = input()
#s="aaaccacabaababc"
num = func( s, "")

print(num)

Fixed submission:
# 再帰関数
# 入力文字列の最大の正整数を返す
# def func( in_str: str, prev: str ):
#     if len(in_str) == 0:
#         return 0
#     for i in range(len(in_str)):
#         s = in_str[0:i+1]
#         if s == prev:
#             continue
#         else:
#             new_str = in_str[i+1:]
#             ret = func(new_str, s)
#             if ret == -1:
#                 continue
#             return 1 + ret
#
#     return -1

#再帰じゃない
def func( in_str: str ):
    prev =""
    num_in_str = len(in_str)
    new_str = in_str
    stack_str =[]
    stack_start = []
    stack_i = []
    stack_K = []
    K = 0
    old_i = 0
    is_separate = False
    while(True):
        num = len(new_str)
        if num == 0:
            break
        for i in range(old_i, num):
            s = new_str[0:i+1]
            if s == prev:
                is_separate = False
                continue
            else:
                # 分岐前に状態保存
                #stack_str.append(new_str)
                stack_start.append(num_in_str - len(new_str))
                stack_i.append(i+1)
                stack_K.append(K)

                new_str = new_str[i+1:]

                prev = s
                K += 1
                is_separate = True
                break
        # 失敗したらスタックからもとに戻す
        if is_separate == False:
            #new_str = stack_str.pop()
            start = stack_start.pop()
            new_str = in_str[start:]
            old_i = stack_i.pop()
            K = stack_K.pop()
        else:
            old_i = 0

    return K

s = input()
#s="aabbaa"
#s="aaaccacabaldkfjadhjdhafidhkajhdkfjahdskjhfakhdkfaababc"*1000
#num = func( s, "")
num = func( s )

print(num)