
    Given a customer's payment history represented as a binary sequence of length 2n, where 1 indicates a successful payment and 0 indicates a missed payment, determine how many possible payment patterns exist where the number of successful payments in the first n months equals the number of successful payments in the last n months. This analysis helps assess if the customer's payment reliability has remained consistent over the entire observation period.
    

    
def count_binary_seq(n):
    """
    Given a customer's payment history represented as a binary sequence of length 2n, where 1 indicates a successful payment and 0 indicates a missed payment, determine how many possible payment patterns exist where the number of successful payments in the first n months equals the number of successful payments in the last n months. This analysis helps assess if the customer's payment reliability has remained consistent over the entire observation period.
    

    """
def count_binary_seq(n):
    """
    Given a customer's payment history represented as a binary sequence of length 2n, where 1 indicates a successful payment and 0 indicates a missed payment, determine how many possible payment patterns exist where the number of successful payments in the first n months equals the number of successful payments in the last n months. This analysis helps assess if the customer's payment reliability has remained consistent over the entire observation period.
    

    """
    nCr = 1
    res = 1
    for r in range(1, n + 1):
        nCr = nCr * (n + 1 - r) / r
        res += nCr * nCr
    return res