
    Design a fraud detection algorithm that analyzes credit card transaction patterns represented as binary sequences of length 2n, where each half of the sequence encodes n transaction characteristics. The algorithm must identify patterns where the sum of flags in the first n characteristics matches the sum in the last n characteristics, as these represent balanced, potentially legitimate transaction behaviors. Determine how many such balanced transaction patterns are possible for a given sequence length 2n.
    

    
def count_binary_seq(n):
    """
    Design a fraud detection algorithm that analyzes credit card transaction patterns represented as binary sequences of length 2n, where each half of the sequence encodes n transaction characteristics. The algorithm must identify patterns where the sum of flags in the first n characteristics matches the sum in the last n characteristics, as these represent balanced, potentially legitimate transaction behaviors. Determine how many such balanced transaction patterns are possible for a given sequence length 2n.
    

    """
def count_binary_seq(n):
    """
    Design a fraud detection algorithm that analyzes credit card transaction patterns represented as binary sequences of length 2n, where each half of the sequence encodes n transaction characteristics. The algorithm must identify patterns where the sum of flags in the first n characteristics matches the sum in the last n characteristics, as these represent balanced, potentially legitimate transaction behaviors. Determine how many such balanced transaction patterns are possible for a given sequence length 2n.
    

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