
    Given a user's content interaction history represented as a sequence of 2n actions (where 1 indicates a like and 0 indicates a dislike), determine how many possible interaction patterns exist where the number of likes in the first n interactions equals the number of likes in the last n interactions. This pattern analysis helps identify consistent user behavior patterns for content recommendation optimization.
    

    
def count_binary_seq(n):
    """
    Given a user's content interaction history represented as a sequence of 2n actions (where 1 indicates a like and 0 indicates a dislike), determine how many possible interaction patterns exist where the number of likes in the first n interactions equals the number of likes in the last n interactions. This pattern analysis helps identify consistent user behavior patterns for content recommendation optimization.
    

    """
def count_binary_seq(n):
    """
    Given a user's content interaction history represented as a sequence of 2n actions (where 1 indicates a like and 0 indicates a dislike), determine how many possible interaction patterns exist where the number of likes in the first n interactions equals the number of likes in the last n interactions. This pattern analysis helps identify consistent user behavior patterns for content recommendation optimization.
    

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