def caculate_standar_deviation(data):
    def calculate_mean(values):
        total = sum(float(value) for value in values)
        return total / len(values)

    def calculate_standard_deviation(values, mean):
        variance = sum((float(value) - mean) ** 2 for value in values) / len(values)
        return variance ** 0.5

    results = {}
    for user in data:
        values = data[user]
        mean = calculate_mean(values)
        stddev = calculate_standard_deviation(values, mean)
        results[user] = stddev

    return results


def score(alluser_mhs24h, hash_percent=1):
    hashrate_values = [obj["mhs24h"] for obj in alluser_mhs24h]

    total_hashrate = sum(hashrate_values)

    result = {}

    for item in alluser_mhs24h:
        user = item["user"]
        mhs24h = item["mhs24h"]
        result[user] = (mhs24h / total_hashrate) * hash_percent

    return result


__all__ = ["caculate_standar_deviation", "score"]