from random import *
from os import path, mkdir
from itertools import chain

dir = '../tests'
test = 0
seed('ololo')

def printTest(a):
    global test
    if not (path.exists(dir)):
        mkdir(dir)
    test += 1
    #print(test)
    ouf = open(dir + "/%02d" % test, 'w')
    print(len(a), file=ouf)
    print(' '.join(map(str, a)),file=ouf)

    ouf.close()

def genRandomTest(n, maxH):
    result = [randint(1, maxH) for _ in range(n)]
    result.sort(reverse=True)
    return result
    
def genEqualTest(n, h):
    return [h for _ in range(n)]
    
def genBlockTest(blocks):
    #blocks = [(len, minH, maxH)]
    result = []
    for i in range(len(blocks)):
        result.extend([randint(blocks[i][1], blocks[i][2]) for _ in range(blocks[i][0])])
    result.sort(reverse = True)
    return result

def genStairTest(n):
    return [n - i for i in range(n)]
    
printTest([5, 2, 1])
printTest([1])
printTest([1] * 2)
printTest([1] * 20)
printTest([1] * 1000)
printTest([2])
printTest([5])
printTest([239])
printTest([1000])
printTest([1000] + [1] * 999)
printTest(genEqualTest(1000, 1000))
printTest([1000] * 500 + [1] * 500)
printTest([1000 - i for i in range(1000)])

for i in [10, 20, 30, 50]:
    for j in [10, 20, 30, 50]:
        printTest(genRandomTest(i, j))

printTest(genRandomTest(50, 500))
printTest(genEqualTest(50, 75))
printTest(genStairTest(60))
printTest(genBlockTest([[20, 500, 1000], [20, 250, 400], [20, 1, 200]]))

printTest(genRandomTest(300, 1000))
printTest(genStairTest(500))
printTest(genBlockTest([[10, 1000, 1000], [800, 1, 800]]))

printTest(genRandomTest(1000, 1000))
printTest(genRandomTest(1000, 1000))
printTest(genRandomTest(1000, 1000))
printTest(genRandomTest(1000, 1000))
printTest(genStairTest(1000))
printTest(genBlockTest([[950, 500, 1000], [50, 100, 500]]))

