Buggy python submission (verdict: Time Limit Exceeded):
def isort(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

def ssort(A, n):
    global cnt
    cnt = 0
    m = max(min(int(n / 3), 100), 1)
    G = [m * 3 - 3 * (i + 1) + 1 for i in range(m - 1)]
    G.append(1)
    print(m)
    print(" ".join([str(g) for g in G]))
    for g in G:
        isort(A, n, g)

n = int(input())
A = [int(input()) for _ in range(n)]
ssort(A, n)
print(cnt)
for a in A:
    print(a)

Fixed submission:
import sys

def isort(A, n, g):
    cnt = 0
    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
    return cnt

def ssort(A, n):
    cnt = 0
    G = []
    h = 1
    while h <= n:
        G.append(h)
        h = 3 * h + 1
    m = len(G)
    G.reverse()
    print(m)
    print(*G, sep = " ")
    for g in G:
        cnt += isort(A, n, g)
    return cnt

n = int(input())
A = list(map(int, sys.stdin.readlines()))
cnt = ssort(A, n)
print(cnt)
print(*A, sep = "\n")

Buggy python submission (verdict: Time Limit Exceeded):
def isort(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

def ssort(A, n):
    global cnt
    cnt = 0
    m = max(min(int(n / 3), 100), 1)
    G = [m * 3 - 3 * (i + 1) + 1 for i in range(m - 1)]
    G.append(1)
    print(m)
    print(" ".join([str(g) for g in G]))
    for g in G:
        isort(A, n, g)

n = int(input())
A = [int(input()) for _ in range(n)]
ssort(A, n)
print(cnt)
for a in A:
    print(a)

Fixed submission:
import sys

def isort(A, n, g):
    cnt = 0
    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
    return cnt

def ssort(A, n):
    cnt = 0
    G = []
    h = 1
    while h <= n:
        G.append(h)
        h = 3 * h + 1
    m = len(G)
    G.reverse()
    print(m)
    print(*G, sep = " ")
    for g in G:
        cnt += isort(A, n, g)
    return cnt

n = int(input())
A = list(map(int, sys.stdin.readlines()))
cnt = ssort(A, n)
print(cnt)
print(*A, sep = "\n")

Buggy python submission (verdict: Time Limit Exceeded):
def isort(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

def ssort(A, n):
    global cnt
    cnt = 0
    m = max(min(int(n / 3), 100), 1)
    G = [m * 3 - 3 * (i + 1) + 1 for i in range(m - 1)]
    G.append(1)
    print(m)
    print(" ".join([str(g) for g in G]))
    for g in G:
        isort(A, n, g)

n = int(input())
A = [int(input()) for _ in range(n)]
ssort(A, n)
print(cnt)
for a in A:
    print(a)

Fixed submission:
import sys

def isort(A, n, g):
    cnt = 0
    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
    return cnt

def ssort(A, n):
    cnt = 0
    G = []
    h = 1
    while h <= n:
        G.append(h)
        h = 3 * h + 1
    m = len(G)
    G.reverse()
    print(m)
    print(*G, sep = " ")
    for g in G:
        cnt += isort(A, n, g)
    return cnt

n = int(input())
A = list(map(int, sys.stdin.readlines()))
cnt = ssort(A, n)
print(cnt)
print(*A, sep = "\n")

Buggy python submission (verdict: Time Limit Exceeded):
def isort(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

def ssort(A, n):
    global cnt
    cnt = 0
    m = max(min(int(n / 3), 100), 1)
    G = [m * 3 - 3 * (i + 1) + 1 for i in range(m - 1)]
    G.append(1)
    print(m)
    print(" ".join([str(g) for g in G]))
    for g in G:
        isort(A, n, g)

n = int(input())
A = [int(input()) for _ in range(n)]
ssort(A, n)
print(cnt)
for a in A:
    print(a)

Fixed submission:
import sys

def isort(A, n, g):
    cnt = 0
    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
    return cnt

def ssort(A, n):
    cnt = 0
    G = []
    h = 1
    while h <= n:
        G.append(h)
        h = 3 * h + 1
    m = len(G)
    G.reverse()
    print(m)
    print(*G, sep = " ")
    for g in G:
        cnt += isort(A, n, g)
    return cnt

n = int(input())
A = list(map(int, sys.stdin.readlines()))
cnt = ssort(A, n)
print(cnt)
print(*A, sep = "\n")

Buggy python submission (verdict: Time Limit Exceeded):
def isort(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

def ssort(A, n):
    global cnt
    cnt = 0
    m = max(min(int(n / 3), 100), 1)
    G = [m * 3 - 3 * (i + 1) + 1 for i in range(m - 1)]
    G.append(1)
    print(m)
    print(" ".join([str(g) for g in G]))
    for g in G:
        isort(A, n, g)

n = int(input())
A = [int(input()) for _ in range(n)]
ssort(A, n)
print(cnt)
print("\n".join([str(a) for a in A]))

Fixed submission:
import sys

def isort(A, n, g):
    cnt = 0
    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
    return cnt

def ssort(A, n):
    cnt = 0
    G = []
    h = 1
    while h <= n:
        G.append(h)
        h = 3 * h + 1
    m = len(G)
    G.reverse()
    print(m)
    print(*G, sep = " ")
    for g in G:
        cnt += isort(A, n, g)
    return cnt

n = int(input())
A = list(map(int, sys.stdin.readlines()))
cnt = ssort(A, n)
print(cnt)
print(*A, sep = "\n")

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = [int(input()) for _ in range(n)]

def isort(n, g):
    global A
    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

def ssort(n):
    global cnt
    global A
    cnt = 0
    m = max(min(int(n / 3), 100), 1)
    G = [m * 3 - 3 * (i + 1) + 1 for i in range(m - 1)]
    G.append(1)
    print(m)
    print(" ".join([str(g) for g in G]))
    for g in G:
        isort(A, n, g)

ssort(n)
print(cnt)
print("\n".join([str(a) for a in A]))

Fixed submission:
import sys

def isort(A, n, g):
    cnt = 0
    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
    return cnt

def ssort(A, n):
    cnt = 0
    G = []
    h = 1
    while h <= n:
        G.append(h)
        h = 3 * h + 1
    m = len(G)
    G.reverse()
    print(m)
    print(*G, sep = " ")
    for g in G:
        cnt += isort(A, n, g)
    return cnt

n = int(input())
A = list(map(int, sys.stdin.readlines()))
cnt = ssort(A, n)
print(cnt)
print(*A, sep = "\n")

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [int(input()) for _ in range(n)]

def isort(n, g):
    global A
    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

def ssort(n):
    global cnt
    global A
    cnt = 0
    m = max(min(int(n / 3), 100), 1)
    G = [m * 3 - 3 * (i + 1) + 1 for i in range(m - 1)]
    G.append(1)
    print(m)
    print(" ".join([str(g) for g in G]))
    for g in G:
        isort(n, g)

ssort(n)
print(cnt)
print("\n".join([str(a) for a in A]))

Fixed submission:
import sys

def isort(A, n, g):
    cnt = 0
    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
    return cnt

def ssort(A, n):
    cnt = 0
    G = []
    h = 1
    while h <= n:
        G.append(h)
        h = 3 * h + 1
    m = len(G)
    G.reverse()
    print(m)
    print(*G, sep = " ")
    for g in G:
        cnt += isort(A, n, g)
    return cnt

n = int(input())
A = list(map(int, sys.stdin.readlines()))
cnt = ssort(A, n)
print(cnt)
print(*A, sep = "\n")