def hash_code(key, HASH_SIZE):
    """
    Return the hash value of given key and the size of hash table

    :param key: given key
    :type key: str
    :param HASH_SIZE: size of hash table
    :type HASH_SIZE: int
    :return: hash value
    :rtype: int
    """
    n = len(key)
    res = 0
    for i in range(n):
        # hash(abc) = (a * 33^2 + b * 33 + c) % M
        #           = (33(33(33 * 0 + a) + b) + c) % M
        #           = (33(33(33 * 0 + a) % M + b) % M + c) % M
        res = 33 * res + ord(key[i])
        res %= HASH_SIZE
    return res