Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list()
for i in range(0, n):
    A.append(int(input()))

G = [1]
cnt = 0

for l in range(1, 100):
    h = 3 * G[l - 1] + 1
    if(h > n):
        m = l
        break
    else:
        G.append(3*G[l-1] + 1)
for g in reversed(G):
    for t in range(g, n):
        v = A[t]
        j = t - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v


print(m)
print(" ".join(str(x) for x in reversed(G)))
print(cnt)

print("\n".join(str(x) for x in A))

Fixed submission:
n = int(input())
A = list()
G = [1]
cnt = 0

for i in range(0, n):
    A.append(int(input()))


def insertion_sort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v


# G[i] = 3*Gi-1 + 1
def shell_sort():
    for i in range(1, 101):
        h = 3 * G[0] + 1
        if h > n:  # h???n?¶???????????????§?????????4n+3*2n-1+1
            break
        else:
            G.insert(0, h)
    for g in G:
        insertion_sort(A, n, g)

shell_sort()
print(len(G))
print(" ".join(str(x) for x in G))
print(cnt)
print("\n".join(str(x) for x in A))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list()
for i in range(0, n):
    A.append(int(input()))

G = [1]  # G[0]????????¨?????????
cnt = 0

# G[i] = 3*Gi-1 + 1
for i in range(1, 100):
    h = 3 * G[i - 1] + 1
    if(h > n):  # h???n?¶???????????????§??????
        m = i
        break
    else:
        G.append(h)


for g in reversed(G):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v


print(m)
print(" ".join(str(x) for x in reversed(G)))
print(cnt)

print("\n".join(str(x) for x in A))

Fixed submission:
n = int(input())
A = list()
G = [1]
cnt = 0

for i in range(0, n):
    A.append(int(input()))


def insertion_sort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v


# G[i] = 3*Gi-1 + 1
def shell_sort():
    for i in range(1, 101):
        h = 3 * G[0] + 1
        if h > n:  # h???n?¶???????????????§?????????4n+3*2n-1+1
            break
        else:
            G.insert(0, h)
    for g in G:
        insertion_sort(A, n, g)

shell_sort()
print(len(G))
print(" ".join(str(x) for x in G))
print(cnt)
print("\n".join(str(x) for x in A))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list()
for i in range(0, n):
    A.append(int(input()))
m = 0
cnt = 0
G = [1]
flag = True
# G[i] = 3*Gi-1 + 1
for i in range(1, 100):
    h = 3 * G[0] + 1
    if h > n:  # h???n?¶???????????????§?????????4n+3*2n-1+1
        m = i
        break
    else:
        G.insert(0, h)


for g in G:
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v


print(m)
print(" ".join(str(x) for x in G))
print(cnt)

print("\n".join(str(x) for x in A))

Fixed submission:
n = int(input())
A = list()
G = [1]
cnt = 0

for i in range(0, n):
    A.append(int(input()))


def insertion_sort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v


# G[i] = 3*Gi-1 + 1
def shell_sort():
    for i in range(1, 101):
        h = 3 * G[0] + 1
        if h > n:  # h???n?¶???????????????§?????????4n+3*2n-1+1
            break
        else:
            G.insert(0, h)
    for g in G:
        insertion_sort(A, n, g)

shell_sort()
print(len(G))
print(" ".join(str(x) for x in G))
print(cnt)
print("\n".join(str(x) for x in A))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list()
for i in range(0, n):
    A.append(int(input()))
m = 0
cnt = 0
G = [1]

# G[i] = 3*Gi-1 + 1
for i in range(1, 101):
    h = 3 * G[0] + 1
    if h > n:  # h???n?¶???????????????§?????????4n+3*2n-1+1
        m = i
        break
    else:
        G.insert(0, h)


for g in G:
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v


print(m)
print(" ".join(str(x) for x in G))
print(cnt)

print("\n".join(str(x) for x in A))

Fixed submission:
n = int(input())
A = list()
G = [1]
cnt = 0

for i in range(0, n):
    A.append(int(input()))


def insertion_sort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v


# G[i] = 3*Gi-1 + 1
def shell_sort():
    for i in range(1, 101):
        h = 3 * G[0] + 1
        if h > n:  # h???n?¶???????????????§?????????4n+3*2n-1+1
            break
        else:
            G.insert(0, h)
    for g in G:
        insertion_sort(A, n, g)

shell_sort()
print(len(G))
print(" ".join(str(x) for x in G))
print(cnt)
print("\n".join(str(x) for x in A))