import math
import random

#n = 6095.0
n = 1
total = 0		#Total no of keys generated
groupSize = 1	#Group size, if keys are in groups
alpha = 0.95	#Zipf's parameter
keys = []
bitLen = 40
digits = "0123456789abcdef"
file = "keys.txt"

f = open(file, "w")

#Totoal no of key groups to generate
for i in range (1, 200001):
    if i % 10000 == 0:
        print i
    if n == 1:
        val = 1
    else:
        val = math.floor(n/(math.pow(i,alpha)) + 0.5)
    total += val * groupSize

    for k in range (0, groupSize):
        key = ""
        for l in range (0, bitLen):
            for x in random.sample(digits, 1):
                key += x
        f.write(key + '\t' + str(int(val)) + '\n')
        if key in keys:
            print "DUPLICATE"
            quit()
        keys.append(key)
f.close()
print total
