Problem p03394 (python)

Fixed submission:
n = int(input())
h = 30000

if n == 3:
    print("2 5 63")
    exit()
if n == 4:
    print("2 5 20 63")
    exit()
if n == 5:
    print("2 5 20 30 63")
    exit()


pret = [2, 3, 4]
it_count = int(n/4) + 1
pret.extend([6*i for i in range(1, it_count)])
pret.extend( [6*i + 2 for i in range(1, it_count)])
pret.extend([6*i +3 for i in range(1, it_count)])
pret.extend(  [6*i + 4 for i in range(1, it_count)])

pret.sort()
ret = pret[:n]


sum_of_ret = sum(ret) % 6
if sum_of_ret == 2:
    ret.remove(8)
    ret.append(6* (it_count))
if sum_of_ret == 3:
    ret.remove(9)
    ret.append(6* (it_count))
if sum_of_ret == 5:
    ret.remove(9)
    if not 6* (it_count - 1) + 4 in ret:
        ret.append(6* (it_count - 1) + 4)
    else:
        ret.append(6* (it_count) + 4)


print(" ".join(list(map(str,ret))))

Buggy submission (verdict: Runtime Error):
n = int(input())
h = 30000

if n == 3:
    print("2 5 63")
    exit()
if n == 4:
    print("2 5 20 63")
    exit()
if n == 5:
    print("2 5 20 30 63")
    exit()


pret = [2, 3, 4]
it_count = int(n/4)
pret.extend([6*i for i in range(1, it_count)])
pret.extend( [6*i + 2 for i in range(1, it_count)])
pret.extend([6*i +3 for i in range(1, it_count)])
pret.extend(  [6*i + 4 for i in range(1, it_count)])

pret.sort()
ret = pret[:n]


sum_of_ret = sum(ret) % 6
if sum_of_ret == 2:
    ret.remove(8)
    ret.append(6* (it_count))
if sum_of_ret == 3:
    ret.remove(9)
    ret.append(6* (it_count))
if sum_of_ret == 5:
    ret.remove(9)
    ret.append(6* (it_count) + 4)


print(" ".join(list(map(str,ret))))

Buggy submission (verdict: Runtime Error):
n = int(input())

h = 30000

if n == 3:
    print("2 5 63")
    exit()
if n == 4:
    print("2 5 20 63")
    exit()
if n == 5:
    print("2 5 63 20 30")
    exit()


pret = [2, 3, 4]
it_count = int(n/4) + 1
pret.extend([6*i for i in range(1, it_count)])
pret.extend( [6*i + 2 for i in range(1, it_count)])
pret.extend([6*i +3 for i in range(1, it_count)])
pret.extend(  [6*i + 4 for i in range(1, it_count)])

ret = pret[:n]


sum_of_ret = sum(ret) % 6
if sum_of_ret == 2:
    ret.remove(8)
    ret.append(6* (it_count+1))
if sum_of_ret == 3:
    ret.remove(9)
    ret.append(6* (it_count+1))
if sum_of_ret == 4:
    ret.remove(10)
    ret.append(6* (it_count+1))
if sum_of_ret == 5:
    ret.remove(9)
    ret.append(6* (it_count+1) + 4)


print(" ".join(ret))

Buggy submission (verdict: Runtime Error):

n = int(input())

h = 30000

if n == 3:
    print("2 5 63")
    exit()
if n == 4:
    print("2 5 20 63")
    exit()
if n == 5:
    print("2 5 63 20 30")
    exit()


pret = [2, 3, 4]
it_count = int(n/4) + 1
pret.extend([6*i for i in range(1, it_count)])
pret.extend( [6*i + 2 for i in range(1, it_count)])
pret.extend([6*i +3 for i in range(1, it_count)])
pret.extend(  [6*i + 4 for i in range(1, it_count)])

ret = pret[:n]


sum_of_ret = sum(ret) % 6
if sum_of_ret == 2:
    ret.remove(8)
    ret.append(6* (it_count+1))
if sum_of_ret == 3:
    ret.remove(9)
    ret.append(6* (it_count+1))
if sum_of_ret == 4:
    ret.remove(10)
    ret.append(6* (it_count+1))
if sum_of_ret == 5:
    ret.remove(9)
    ret.append(6* (it_count+1) + 4)


print(" ".join(ret))

Buggy submission (verdict: Runtime Error):
"""
和の最大公倍数1ではない
2n 3n

素数2つを含む
6n, 6n+2,6n+3 6n+4

"""



n = int(input())

h = 30000

if n == 3:
    print("2 5 63")
    exit()
if n == 4:
    print("2 5 20 63")
    exit()
if n == 5:
    print("2 5 63 20 30")
    exit()


pret = [2, 3, 4]
it_count = int(n/4) + 1
pret.extend([6*i for i in range(1, it_count)])
pret.extend( [6*i + 2 for i in range(1, it_count)])
pret.extend([6*i +3 for i in range(1, it_count)])
pret.extend(  [6*i + 4 for i in range(1, it_count)])

ret = pret[:n]


sum_of_ret = sum(ret) % 6
if sum_of_ret == 2:
    ret.remove(8)
    ret.append(6* (it_count+1))
if sum_of_ret == 3:
    ret.remove(9)
    ret.append(6* (it_count+1))
if sum_of_ret == 4:
    ret.remove(10)
    ret.append(6* (it_count+1))
if sum_of_ret == 5:
    ret.remove(9)
    ret.append(6* (it_count+1) + 4)


print(" ".join(ret))