
    Design a fraud detection algorithm that analyzes transaction pattern sequences of length 2n, where each transaction is marked as legitimate (0) or suspicious (1), and counts all possible sequences where the number of suspicious transactions in the first n transactions equals the number in the last n transactions. This pattern matching helps identify balanced fraud risk patterns across customer transaction history segments.
    

    
def count_binary_seq(n):
    """
    Design a fraud detection algorithm that analyzes transaction pattern sequences of length 2n, where each transaction is marked as legitimate (0) or suspicious (1), and counts all possible sequences where the number of suspicious transactions in the first n transactions equals the number in the last n transactions. This pattern matching helps identify balanced fraud risk patterns across customer transaction history segments.
    

    """
def count_binary_seq(n):
    """
    Design a fraud detection algorithm that analyzes transaction pattern sequences of length 2n, where each transaction is marked as legitimate (0) or suspicious (1), and counts all possible sequences where the number of suspicious transactions in the first n transactions equals the number in the last n transactions. This pattern matching helps identify balanced fraud risk patterns across customer transaction history segments.
    

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