
    Design a fraud detection algorithm that analyzes transaction sequences of length 2n, where each transaction is flagged as either suspicious (1) or normal (0), and determines how many possible sequence patterns exist where the count of suspicious transactions in the first n transactions equals the count in the last n transactions. The equal distribution of suspicious flags between the two halves of the sequence could indicate coordinated fraudulent behavior requiring investigation.
    

    
def count_binary_seq(n):
    """
    Design a fraud detection algorithm that analyzes transaction sequences of length 2n, where each transaction is flagged as either suspicious (1) or normal (0), and determines how many possible sequence patterns exist where the count of suspicious transactions in the first n transactions equals the count in the last n transactions. The equal distribution of suspicious flags between the two halves of the sequence could indicate coordinated fraudulent behavior requiring investigation.
    

    """
def count_binary_seq(n):
    """
    Design a fraud detection algorithm that analyzes transaction sequences of length 2n, where each transaction is flagged as either suspicious (1) or normal (0), and determines how many possible sequence patterns exist where the count of suspicious transactions in the first n transactions equals the count in the last n transactions. The equal distribution of suspicious flags between the two halves of the sequence could indicate coordinated fraudulent behavior requiring investigation.
    

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