Problem p02721 (python)

Fixed submission:
N, K, C = [int(input_) for input_ in input().split(" ")]
    
tick_cross = input()
    
def find_earliest_work_days(K, C, tick_cross):
    """
    Find the list of the earliest day in all possible days for the n-th 
    work day.
    
    Parameters:
    K (int): The number of work days.
    C (int): Minimum interval between the previous work day and the 
             next work day.
    tick_cross (str): The character string of days he can go to work.
             
    Returns:
    List[int]: The list of the earliest day in all possible days for 
               the n-th work day.
    """
    
    N = len(tick_cross)
        
    day = 0
    earliest_work_days = []
    number_of_work_days = len(earliest_work_days)
    while (day < N) and (number_of_work_days < K):
        if tick_cross[day] == "o":
            earliest_work_days.append(day+1)
            number_of_work_days = len(earliest_work_days)
            day += C + 1
        else:
            day += 1
            
    return earliest_work_days
    
def find_latest_work_days(K, C, tick_cross): 
    """
    Find the list of the latest day in all possible days for the n-th 
    work day.
    
    Parameters
    K (int): The number of work days.
    C (int): Minimum interval between the previous work day and the 
             next work day.
    tick_cross (str): The character string of days he can go to work.
             
    Returns:
    List[int]: The list of the latest day in all possible days for 
               the n-th work day.
    """
    
    N = len(tick_cross)
        
    day = N - 1
    latest_work_days = []
    number_of_work_days = len(latest_work_days)
    while (day >= 0) and (number_of_work_days < K):
        if tick_cross[day] == "o":
            latest_work_days.append(day+1)
            number_of_work_days = len(latest_work_days)
            day -= (C + 1)
        else:
            day -= 1
            
    return sorted(latest_work_days)
                
earliest_work_days = find_earliest_work_days(K, C, tick_cross)
latest_work_days = find_latest_work_days(K, C, tick_cross)
for earliest, latest in zip(earliest_work_days, latest_work_days):
    if earliest == latest:
        print(earliest)

Buggy submission (verdict: Runtime Error):
N, K, C = [int(input_) for input_ in input().split(" ")]
    
tick_cross = input()
    
def find_earliest_work_days(C, tick_cross):
    """
    Find the list of the earliest day in all possible days for the n-th 
    work day.
    
    Parameters:
    C (int): Minimum interval between the previous work day and the 
             next work day.
    tick_cross (str): The character string of days he can go to work.
             
    Returns:
    List[int]: The list of the earliest day in all possible days for 
               the n-th work day.
    """
    N = len(tick_cross)
        
    day = 0
    earliest_work_days = []
    while day <= N:
        if tick_cross[day] == "o":
            earliest_work_days.append(day+1)
            day += C + 1
        else:
            day += 1
            
    return earliest_work_days
    
def find_latest_work_days(C, tick_cross): 
    """
    Find the list of the latest day in all possible days for the n-th 
    work day.
    
    Parameters:
    C (int): Minimum interval between the previous work day and the 
             next work day.
    tick_cross (str): The character string of days he can go to work.
             
    Returns:
    List[int]: The list of the latest day in all possible days for 
               the n-th work day.
    """
    
    N = len(tick_cross)
        
    day = N - 1
    latest_work_days = []
    while day >= 0:
        if tick_cross[day] == "o":
            latest_work_days.append(day+1)
            day -= C + 1
        else:
            day -= 1
            
    return sorted(latest_work_days)
                
earliest_work_days = find_earliest_work_days(C, tick_cross)
latest_work_days = find_latest_work_days(C, tick_cross)
for earliest, latest in zip(earliest_work_days, latest_work_days):
    if earliest == latest:
        print(earliest)

Buggy submission (verdict: Runtime Error):
N, K, C = [int(input_) for input_ in input().split(" ")]
    
tick_cross = input()
    
def find_earliest_work_days(C, tick_cross):
    """
    Find the list of the earliest day in all possible days for the n-th 
    work day.
    
    Parameters:
    C (int): Minimum interval between the previous work day and the 
             next work day.
    tick_cross (str): The character string of days he can go to work.
             
    Returns:
    List[int]: The list of the earliest day in all possible days for 
               the n-th work day.
    """
    N = len(tick_cross)
        
    day = 0
    earliest_work_days = []
    while day <= N:
        if tick_cross[day] == "o":
            earliest_work_days.append(day+1)
            day += C + 1
        else:
            day += 1
            
    return earliest_work_days
    
def find_latest_work_days(C, tick_cross): 
    """
    Find the list of the latest day in all possible days for the n-th 
    work day.
    
    Parameters:
    C (int): Minimum interval between the previous work day and the 
             next work day.
    tick_cross (str): The character string of days he can go to work.
             
    Returns:
    List[int]: The list of the latest day in all possible days for 
               the n-th work day.
    """
    
    N = len(tick_cross)
        
    day = N - 1
    latest_work_days = []
    while day >= 0:
        if tick_cross[day] == "o":
            latest_work_days.append(day+1)
            day -= C + 1
        else:
            day -= 1
            
    return sorted(latest_work_days)
                
earliest_work_days = find_earliest_work_days(C, tick_cross)
latest_work_days = find_latest_work_days(C, tick_cross)
for earliest, latest in zip(earliest_work_days, latest_work_days):
    if earliest == latest:
        print(earliest)

Buggy submission (verdict: Runtime Error):
from typing import List

N_K_C: List[int] = [int(input_) for input_ in input().split(" ")]
N: int = N_K_C[0]
K: int = N_K_C[1]
C: int = N_K_C[2]
    
tick_cross: str = input()
    
def find_earliest_work_day(nth: int, C: int, tick_cross: str) -> int:
    """
    Find the earliest day in all possible days for the n-th work day.
    
    Parameters:
    nth (int): The number indicating how many days he's worked.
    C (int): Minimum interval between the previous work day and the 
             next work day.
    tick_cross (str): The character string of days he can go to work.
             
    Returns:
    int: The earliest day in all possible days for the n-th work day.
    """
    N: int = len(tick_cross)
        
    day: int = 0
    counter: int = 0
    while True:
        if tick_cross[day] == "o":
            counter += 1
            if counter == nth:
                return day + 1
            else:
                day += C + 1
        else:
            day += 1
            
        if day > N:
            raise IndexError
    
def find_latest_work_day(nth: int, C: int, tick_cross: str) -> int: 
    """
    Find the latest day in all possible days for the n-th work day.
    
    Parameters:
    nth (int): The number indicating how many more days he must work.
    C (int): Minimum interval between the previous work day and the 
             next work day.
    tick_cross (str): The character string of days he can go to work.
             
    Returns:
    int: The latest day in all possible days for the n-th work day.
    """
    
    N: int = len(tick_cross)
        
    day: int = N - 1
    counter: int = 0
    while True:
        if tick_cross[day] == "o":
            counter += 1
            if counter == (nth + 1):
                return day + 1
            else:
                day -= C + 1
        else:
            day -= 1
            
        if day < 0:
            raise IndexError
                
for nth_work_day in range(1, K+1):
    try:
        earliest_work_day = find_earliest_work_day(nth_work_day,
                                                   C, tick_cross)
        latest_work_day = find_latest_work_day(K - nth_work_day,
                                               C, tick_cross)
    except IndexError:
        break
    else:
        if earliest_work_day == latest_work_day:
            print(earliest_work_day)

Buggy submission (verdict: Runtime Error):
from typing import List

N_K_C: List[int] = [int(input_) for input_ in input().split(" ")]
N: int = N_K_C[0]
K: int = N_K_C[1]
C: int = N_K_C[2]
    
tick_cross: str = input()
    
def find_earliest_work_day(nth: int, C: int, tick_cross: str) -> int:
    """
    Find the earliest day in all possible days for the n-th work day.
    
    Parameters:
    nth (int): The number indicating how many days he's worked.
    C (int): Minimum interval between the previous work day and the 
             next work day.
    tick_cross (str): The character string of days he can go to work.
             
    Returns:
    int: The earliest day in all possible days for the n-th work day.
    """
    N: int = len(tick_cross)
        
    day: int = 0
    counter: int = 0
    while True:
        if tick_cross[day] == "o":
            counter += 1
            if counter == nth:
                return day + 1
            else:
                day += C + 1
        else:
            day += 1
            
        if day > N:
            raise IndexError
    
def find_latest_work_day(nth: int, C: int, tick_cross: str) -> int: 
    """
    Find the latest day in all possible days for the n-th work day.
    
    Parameters:
    nth (int): The number indicating how many more days he must work.
    C (int): Minimum interval between the previous work day and the 
             next work day.
    tick_cross (str): The character string of days he can go to work.
             
    Returns:
    int: The latest day in all possible days for the n-th work day.
    """
    
    N: int = len(tick_cross)
        
    day: int = N - 1
    counter: int = 0
    while True:
        if tick_cross[day] == "o":
            counter += 1
            if counter == (nth + 1):
                return day + 1
            else:
                day -= C + 1
        else:
            day -= 1
            
        if day < 0:
            raise IndexError
                
for nth_work_day in range(1, K+1):
    try:
        earliest_work_day = find_earliest_work_day(nth_work_day,
                                                   C, tick_cross)
        latest_work_day = find_latest_work_day(K - nth_work_day,
                                               C, tick_cross)
    except IndexError:
        break
    else:
        if earliest_work_day == latest_work_day:
            print(earliest_work_day)