
    Design an algorithm for a social media content recommendation system that determines the number of possible ways to arrange content in a feed of n consecutive slots, where each slot can show one of k different content types (posts, shares, likes, comments), with the constraint that no more than 2 consecutive slots can display the same content type. This diversification approach aims to maintain user engagement by preventing content monotony while ensuring a balanced content mix in the user's feed.
    

    
def count_no_of_ways(n, k):
    """
    Design an algorithm for a social media content recommendation system that determines the number of possible ways to arrange content in a feed of n consecutive slots, where each slot can show one of k different content types (posts, shares, likes, comments), with the constraint that no more than 2 consecutive slots can display the same content type. This diversification approach aims to maintain user engagement by preventing content monotony while ensuring a balanced content mix in the user's feed.
    

    """
def count_no_of_ways(n, k):
    """
    Design an algorithm for a social media content recommendation system that determines the number of possible ways to arrange content in a feed of n consecutive slots, where each slot can show one of k different content types (posts, shares, likes, comments), with the constraint that no more than 2 consecutive slots can display the same content type. This diversification approach aims to maintain user engagement by preventing content monotony while ensuring a balanced content mix in the user's feed.
    

    """
    dp = [0] * (n + 1)
    total = k
    mod = 1000000007
    dp[1] = k
    dp[2] = k * k
    for i in range(3, n + 1):
        dp[i] = (k - 1) * (dp[i - 1] + dp[i - 2]) % mod
    return dp[n]