Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
class Daise:
    def __init__(self, info_list):
        self.T = info_list[0]
        self.S = info_list[1]
        self.E = info_list[2]
        self.W = info_list[3]
        self.N = info_list[4]
        self.B = info_list[5]
    
    def change(self, axis):
        if axis == 'S':
            self.T, self.B, self.S, self.N = self.N, self.S, self.T, self.B
        
        elif axis == 'E':
            self.T, self.B, self.E, self.W = self.W, self.E, self.T, self.B
        
        elif axis == 'W':
            self.T, self.B, self.W, self.E = self.E, self.W, self.T, self.B
        
        elif axis == 'N':
            self.T, self.B, self.N, self.S = self.S, self.N, self.T, self.B
        
        elif axis == 'Turn':
            self.S, self.E, self.N, self.W = self.E, self.N, self.W, self.S
    
    def output(self):
        return [self.T, self.S, self.E, self.W, self.N, self.B]


if __name__ == '__main__':
    daiseA = Daise(list(map(str, input().split())))
    daiseB = Daise(list(map(str, input().split())))

    while daiseA.T != daiseB.T:
        daiseB.change('S')
        daiseB.change('S')
        daiseB.change('Turn')   
    
    while daiseA.S != daiseB.S:
        daiseB.change('Turn')
    
    if daiseA.output() == daiseB.output():
        print("Yes")
    else: 
        print('No')


Fixed submission:
import sys


class Daise:
    def __init__(self, info_list):
        self.T = info_list[0]
        self.S = info_list[1]
        self.E = info_list[2]
        self.W = info_list[3]
        self.N = info_list[4]
        self.B = info_list[5]
    
    def change(self, axis):
        if axis == 'S':
            self.T, self.B, self.S, self.N = self.N, self.S, self.T, self.B
        
        elif axis == 'E':
            self.T, self.B, self.E, self.W = self.W, self.E, self.T, self.B
        
        elif axis == 'W':
            self.T, self.B, self.W, self.E = self.E, self.W, self.T, self.B
        
        elif axis == 'N':
            self.T, self.B, self.N, self.S = self.S, self.N, self.T, self.B
        
        elif axis == 'Turn':
            self.S, self.E, self.N, self.W = self.E, self.N, self.W, self.S
    

    def output(self):
        return [self.T, self.S, self.E, self.W, self.N, self.B]
    

    def set_info(self, top, front):
        if front in (self.T, self.B):
            self.change("S")

        while self.S != front:
            self.change('Turn')
 
        while self.T != top:
            self.change('E')



if __name__ == '__main__':
    daiseA = Daise(list(map(str, input().split())))
    daiseB = Daise(list(map(str, input().split())))
    
    for _ in range(4):
        for _ in range(4):
            if daiseA.output() == daiseB.output():
                print('Yes')
                sys.exit()
            for _ in range(4):
                if daiseA.output() == daiseB.output():
                    print('Yes')
                    sys.exit()
                daiseB.change('Turn')
            daiseB.change('S')
        daiseB.change('W')
    print('No')
Buggy python submission (verdict: Runtime Error):
x = int(input)
h = x // 3600
m = x % 3600//60
s = x % 3600 % 60
print('{}:{}:{}'.format(h, m, s))

Fixed submission:
x = int(input())
# x = 46979
h = x // 3600
m = x % 3600//60
s = x % 3600 % 60
print('{}:{}:{}'.format(str(h), str(m), str(s)))
Buggy python submission (verdict: Runtime Error):
num = []
while True:
    n = input()
    a, b = [int(x) for x in n.split()]
    if a == 0 and b == 0:
        break
    num.append([a, b])

for ls in num:
    ls.sort()
    print('{} {}'.format(ls[0], ls[1])

Fixed submission:
num = []
while True:
    n = input()
    a, b = [int(x) for x in n.split()]
    if a == 0 and b == 0:
        break
    num.append([a, b])

for ls in num:
    ls.sort()
    print('{} {}'.format(ls[0], ls[1]))

Buggy python submission (verdict: Runtime Error):
num = []
while True:
    n = input()
    a, b = [int(x) for x in n.split()]
    if a == 0 and b == 0:
        break
    num.append([a, b])

for ls in num:
    ls.sort()
    print('{} {}'.format(ls[0], ls[1])

Fixed submission:
num = []
while True:
    n = input()
    a, b = [int(x) for x in n.split()]
    if a == 0 and b == 0:
        break
    num.append([a, b])

for ls in num:
    ls.sort()
    print('{} {}'.format(ls[0], ls[1]))
Buggy python submission (verdict: Runtime Error):
import math
x = int(input())
c = x * 2 * math.pi
a = x ** 2 * math.pi
print('{:.6f} {:.6f}'.format(c, a))

Fixed submission:
from math import pi

r = float(input())
area = lambda x: r * r * pi
length = lambda x: r * 2 * pi

print("{} {}".format(area(r), length(r)))

Buggy python submission (verdict: Runtime Error):
import math
x = int(input())
c = x * 2 * math.pi
a = x ** 2 * math.pi
print('{:.6f} {:.6f}'.format(c, a))

Fixed submission:
from math import pi

r = float(input())
area = lambda x: r * r * pi
length = lambda x: r * 2 * pi

print("{} {}".format(area(r), length(r)))

Buggy python submission (verdict: Runtime Error):
from math import pi

r = float(input())
area = lambda r: r * r * pi
length = lambda r: r * 2 * pi

print("{} {}".format(length(r), area(r))


Fixed submission:
from math import pi

r = float(input())
area = lambda x: r * r * pi
length = lambda x: r * 2 * pi

print("{} {}".format(area(r), length(r)))
Buggy python submission (verdict: Runtime Error):
def print_fig(h, w):
    for _ in range(h):
        print("#" * w)
    print("")

while True:
    x = input().split()
    print_fig(int(x[0]), int(x[1]))


Fixed submission:
def print_fig(h, w):
    for _ in range(h):
        print("#" * w)
    print("")

while True:
    x = input().split()
    w, h = int(x[0]), int(x[1])
    if (w, h) == (0, 0): break
    print_fig(int(x[0]), int(x[1]))
Buggy python submission (verdict: Runtime Error):
import string
sen = input().lower()

char_dic = {i:0 for i in string.ascii_lowercase}

for j in sen:
    if j in char_dic:
        char_dic[j] += 1
    else:
        pass

for k in string.ascii_letters:
    print("{} : {}".format(k, char_dic[k]))



Fixed submission:
import string, sys
sen = sys.stdin.read().lower()

char_dic = {i:0 for i in string.ascii_lowercase}

for j in sen:
    if j in char_dic:
        char_dic[j] += 1

for k in string.ascii_lowercase:
    print("{} : {}".format(k, char_dic[k]))
Buggy python submission (verdict: Runtime Error):
from collections import deque


def shuffle(target, num):
    que = deque(list(target))
    [que.append(que.popleft()) for _ in range(int(num))]
    return "".join(que)

text = input()
count = input()
while text != '-':
    for _ in range(int(count)):
        n = input()
        text = shuffle(text, n)
    print(text)
    text = input()
    count = input()



Fixed submission:
from collections import deque

def shuffle(target, num):
    que = deque(list(target))
    [que.append(que.popleft()) for _ in range(int(num))]
    return "".join(que)

text = input()
while True:
    if text == "-": break
    count = input()
    for _ in range(int(count)):
        n = input()
        text = shuffle(text, n)
    print(text)
    text = input()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    numlist = []
    for _ in range(n):
        numlist.append(int(input()))

    maxprofit = numlist[1] - numlist[0]
    for i in range(n-1):
        for j in range(i+1, n):
            if numlist[j] - numlist[i] > maxprofit:
                maxprofit = numlist[j] - numlist[i]
    print(maxprofit)


if __name__ == '__main__':
    main()



Fixed submission:
n = int(input())
a0 = int(input())
a1 = int(input())
max_profit = a1 - a0
min_i = min(a1, a0)
for i in range(n-2):
    c=int(input())
    if c - min_i > max_profit:
        max_profit = c - min_i
    min_i = min(min_i, c)
print(max_profit)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    numlist = []
    for _ in range(n):
        numlist.append(int(input()))

    maxprofit = numlist[1] - numlist[0]
    for i in range(n-1):
        if maxprofit < max(numlist[i+1:n]) - numlist[i]:
            maxprofit = max(numlist[i+1:n]) - numlist[i]
    print(maxprofit)

if __name__ == '__main__':
    main()



Fixed submission:
n = int(input())
a0 = int(input())
a1 = int(input())
max_profit = a1 - a0
min_i = min(a1, a0)
for i in range(n-2):
    c=int(input())
    if c - min_i > max_profit:
        max_profit = c - min_i
    min_i = min(min_i, c)
print(max_profit)

Buggy python submission (verdict: Time Limit Exceeded):
# とても時間がかかる

def main():
    n = int(input())
    numlist = []
    for _ in range(n):
        numlist.append(int(input()))

    maxprofit = []
    for i in range(n-1):
        maxprofit.append(max(numlist[i+1:n]) - min(numlist[0:i+1]))
    print(max(maxprofit))


if __name__ == '__main__':
    main()



Fixed submission:
n = int(input())
a0 = int(input())
a1 = int(input())
max_profit = a1 - a0
min_i = min(a1, a0)
for i in range(n-2):
    c=int(input())
    if c - min_i > max_profit:
        max_profit = c - min_i
    min_i = min(min_i, c)
print(max_profit)

Buggy python submission (verdict: Time Limit Exceeded):
# とても時間がかかる

def main():
    n = int(input())
    numlist = []
    for _ in range(n):
        numlist.append(int(input()))

    maxprofit = numlist[1] - numlist[0]
    for i in range(n-1):
        x = max(numlist[i+1:n])
        y = min(numlist[0:i+1])
        if maxprofit < x - y:
            maxprofit = x - y
    print(maxprofit)


if __name__ == '__main__':
    main()



Fixed submission:
n = int(input())
a0 = int(input())
a1 = int(input())
max_profit = a1 - a0
min_i = min(a1, a0)
for i in range(n-2):
    c=int(input())
    if c - min_i > max_profit:
        max_profit = c - min_i
    min_i = min(min_i, c)
print(max_profit)
Buggy python submission (verdict: Runtime Error):
from math import sqrt
def main():

    x1, y1, x2, y2 = map(float, input())
    print(sqrt((x2-x1)**2 + (y2-y1)**2))

if __name__ == '__main__':
    main()



Fixed submission:
x1, y1, x2, y2 = map(float, input().split())
dist = ((x2-x1)**2 + (y2-y1)**2)**0.5
print("{:.8f}".format(dist))
Buggy python submission (verdict: Time Limit Exceeded):
class Dice:

    def __init__(self):
        # 初期値がない場合
        # 上, 南、東、西、北、下にそれぞれ1, 2, 3, 4, 5, 6がくる想定
        self.t = 1
        self.s = 2
        self.e = 3
        self.w = 4
        self.n = 5
        self.b = 6
        self.rotway = {"S": 0, "N": 1, "E": 2, "W": 3}

    def __init__(self, t, s, e, w, n, b):
        # 初期値が指定される場合
        self.t = t
        self.s = s
        self.e = e
        self.w = w
        self.n = n
        self.b = b
        self.rotway = {"S": 0, "N": 1, "E": 2, "W": 3}

    def rot(self, way):
        if way == 0:
            self.t, self.s, self.e, self.w, self.n, self.b = self.n, self.t, self.e, self.w, self.b, self.s
        elif way == 1:
            self.t, self.s, self.e, self.w, self.n, self.b = self.s, self.b, self.e, self.w, self.t, self.n
        elif way == 2:
            self.t, self.s, self.e, self.w, self.n, self.b = self.w, self.s, self.t, self.b, self.n, self.e
        elif way == 3:
            self.t, self.s, self.e, self.w, self.n, self.b = self.e, self.s, self.b, self.t, self.n, self.w
        

def main():
    import random

    n = int(input())
    diceList = [[0 for _ in range(6)] for _ in range(n)]
    for i in range(n):
        diceList[i][0],diceList[i][1],diceList[i][2],diceList[i][3],diceList[i][4],diceList[i][5] = map(int, input().split())

    flag = 0

    # 2つ目以降のさいころが、以前のさいころと一致しているか確認していく。
    for i in range(1, n):
        if flag == 1:
            break
        else:
            dice_a = Dice(diceList[i][0],diceList[i][1],diceList[i][2],diceList[i][3],diceList[i][4],diceList[i][5])
            for j in range(i):
                dice_b = Dice(diceList[j][0],diceList[j][1],diceList[j][2],diceList[j][3],diceList[j][4],diceList[j][5])

                for _ in range(1000):
                    if (dice_a.t, dice_a.s, dice_a.e, dice_a.w, dice_a.n, dice_a.b) == (dice_b.t, dice_b.s, dice_b.e, dice_b.w, dice_b.n, dice_b.b):
                        flag = 1
                        break
                    else:
                        seed = random.randint(0, 3)
                        dice_a.rot(seed)

    if flag == 0:
        print("Yes")
    else:
        print("No")



if __name__ == '__main__':
    main()



Fixed submission:
def main():
    n = int(input())
    dices=[]
    same = 0
    for _ in range(n):
        dices.append(list(map(int, input().split())))

    for i in range(n-1):
        for j in range(i+1,n):
            same += check_dice(dices[i], dices[j])
        if same >= 1:
            print('No')
            break

    if same == 0:
        print('Yes')


def check_dice(f, s):
    yes = 0
    for _ in range(4):
        s[0],s[2],s[5],s[3] = s[2],s[5],s[3],s[0]
        for _ in range(4):
            s[1],s[2],s[4],s[3] = s[2],s[4],s[3],s[1]
            if f == s:
                yes = 1

    for _ in range(4):
        s[0],s[1],s[5],s[4] = s[1],s[5],s[4],s[0]
        for _ in range(4):
            s[1],s[2],s[4],s[3] = s[2],s[4],s[3],s[1]
            if f == s:
                yes = 1

    return yes

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
print(x**3)

Fixed submission:
x = int(input())
print (x**3)

Buggy python submission (verdict: Runtime Error):
x = input()
y = x**3
print(y)

Fixed submission:
x = int(input())
print (x**3)
Buggy python submission (verdict: Runtime Error):
print(a*b,2*(a+b),'\n')

Fixed submission:
a, b = map(int, input().split())
area = a * b
perimeter = 2 * (a + b)
print(area, perimeter)
Buggy python submission (verdict: Runtime Error):
def main():
    while True:
        numlst = []
        numlst = list(map(int, input().split()))
        
        print(min(numlst), max(numlst), sum(numlst))

if __name__ == '__main__':
    main()



Fixed submission:
n = int(input())
X = list(map(int, input().split()))

minX = min(X)
maxX = max(X)
sumX = sum(X)
print(minX, maxX, sumX)

Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    lst = list(map(int, input().split()))

    print(min(numlst), max(numlst), sum(numlst))

if __name__ == '__main__':
    main()



Fixed submission:
n = int(input())
X = list(map(int, input().split()))

minX = min(X)
maxX = max(X)
sumX = sum(X)
print(minX, maxX, sumX)
Buggy python submission (verdict: Runtime Error):
def main():
    while True;
        H, W = tuple(map(int, input().split()))
        if (H, W) == (0, 0):
            break
        for i in range(H):
            print("#"*W)

if __name__ == '__main__':
    main()



Fixed submission:
Rect = []
cnt = 0
while True:
    H, W = map(int, input().split())
    if (H, W) == (0, 0):
        break
    Rect.append((H, W))
    cnt += 1

# print(Rect)
# print(Rect[1][1])
for i in range(cnt):
    for _ in range(Rect[i][0]):
        print("#"*Rect[i][1])
    print()
Buggy python submission (verdict: Runtime Error):
def main():

m, n = tuple(map(int, input().split()))
a = [[0 for j in range(n)] for i in range(m)]
b = [0 for j in range(n)]
c = [0 for i in range(m)]

for i in range(m):
    tmplst = list(map(int, input().split()))
    for j in range(n):
        a[i][j] = tmplst[j]

for j in range(n):
    b[j] = int(input())

for i in range(m):
    for j in range(n):
        c[i] += a[i][j] * b[j]
        print(c[i])



if __name__ == '__main__':
    main()


Fixed submission:
n, m = map(int, input().split())
A = [[0 for _ in range(m)] for _ in range(n)]
b = [0 for _ in range(m)]
Ab = [0 for _ in range(n)]

for i in range(n):
    x = list(map(int, input().split()))
    for j in range(m):
        A[i][j] = x[j]

for j in range(m):
    b[j] = int(input())

for i in range(n):
    for j in range(m):
        Ab[i] += A[i][j] * b[j]

for i in range(n):
    print(Ab[i])
Buggy python submission (verdict: Runtime Error):
def main():

    Counter = 0
    Text_W = input()
    while True:
        Text_T = input().lower()
        if "END_OF_TEXT" in Text_T:
            temp = Text_T.split()
            for i in range(len(temp)):
                Counter += 1 if Text_W == temp[i] else 0
            break
        else:
            temp = Text_T.split()
            for i in range(len(temp)):
                Counter += 1 if Text_W == temp[i] else 0

    print (Counter)

if __name__ == '__main__':
    main()
    


Fixed submission:
W = input()
count_W = 0
while True:
    s = input()
    if s == 'END_OF_TEXT':
        break
    else:
        count_W += s.lower().split().count(W)

print(count_W)
Buggy python submission (verdict: Runtime Error):
def main():

    TaroScore = HanaScore = 0
    n = int(input())
    for _ in range(n):
        [Taro, Hana] = list(input().lower().split())

        lenT = len(Taro)
        lenH = len(Hana)

        if Taro == Hana:
            TaroScore += 1
            HanaScore += 1
        
        else:
            for _ in range(min(lenT, lenH)+1):
                if Taro == '' or ord(Taro[0]) < ord(Hana[0]):
                    HanaScore += 3
                    break
                elif Hana == '' or ord(Taro[0]) > ord(Hana[0]):
                    TaroScore += 3
                    break
                else:
                    Taro = Taro[1:]
                    Hana = Hana[1:]

    print(TaroScore, HanaScore)

if __name__ == '__main__':
    main()



Fixed submission:
score_t = score_h = 0
n = int(input())
for _ in range(n):
    animal_t, animal_h = input().split()
    if animal_t == animal_h:
        score_t += 1
        score_h += 1
    elif animal_t > animal_h:
        score_t += 3
    else:
        score_h += 3

print(score_t, score_h)
Buggy python submission (verdict: Runtime Error):
import math

x1, y1, x2, y2 = map(int, input().split())
r = math.sqrt((x1 - x2) **2 + (y1 - y2) **2)
print(r)



Fixed submission:
import math

x1, y1, x2, y2 = map(float, input().split())
r = math.sqrt((x1 - x2) **2 + (y1 - y2) **2)
print(r)
Buggy python submission (verdict: Runtime Error):
a, b =map(int, input().split())
print(a*b, 2*(a+b))


Fixed submission:
a, b =map(int, input().split())
print(a*b, 2*(a+b))

Buggy python submission (verdict: Runtime Error):
a, b =map(int, input().split())
print(a*b, 2*(a+b))



Fixed submission:
a, b =map(int, input().split())
print(a*b, 2*(a+b))
Buggy python submission (verdict: Time Limit Exceeded):
a, b, c = map(int, input().split())
n=0
while True:
    if c%a == 0:
        n += 1
    a += 1
    if a == b:
        break
print(n)



Fixed submission:
a, b, c = map(int, input().split())
n=0
while True:
    if c%a == 0:
        n += 1
    a += 1
    if a > b:
        break
print(n)
Buggy python submission (verdict: Runtime Error):
r = int(input())
pi = 3.14159265358979
print("{:.6f} {:.6f}".format(r**2*pi, 2*r*pi))



Fixed submission:
import math
r = float(input())
pi = math.pi
print("{} {}".format(r*r*pi, 2*r*pi))

Buggy python submission (verdict: Runtime Error):
r = int(input())
pi = 3.14159265358979
print("{:.6f} {:.6f}".format(r**2*pi, 2*r*pi))



Fixed submission:
import math
r = float(input())
pi = math.pi
print("{} {}".format(r*r*pi, 2*r*pi))
Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(1 : n+1):
	if i > n:
		break
	if i % 3 == 0:
		print(" ", i, end="")
	else:
		if i % 10 ==3:
			print(" ", i, end="")



Fixed submission:
n = int(input())
for i in range(1 , n+1):
	if "3" in str(i):
		print(" {}".format(i), end="")
	else:
		if i % 3 == 0:
			print(" {}".format(i), end="")
		else:
			if i % 10 == 3:
				print(" {}".format(i), end="")
print()
Buggy python submission (verdict: Runtime Error):
n = int(input())
cards = []
for i in range(1, n):
	s, r = input().split()
	cards.append((s, int(r)))
for s in "SHCD":
	for r in range(1, 14)
		if (s, r)not in cards:
			print(s, r)



Fixed submission:
c = {
    "S":[0]*13,
    "H":[0]*13,
    "C":[0]*13,
    "D":[0]*13,
    }
n = int(input())
for i in range(n):
	s, num = input().split()
	c[s][int(num)-1]=1
for i in ["S", "H", "C", "D"]:
	for j in range (13):
		if c[i][j] ==0:
			print(i, j+1)
Buggy python submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
a=[]
for i in range(n):
	a.append([int(j) for j in input().split()])
for j in range(n):
	s = 0
	for j in range(m):
		s += a[i][j] * b[j]
	print(s)
	


Fixed submission:
n, m = list(map(int, input().split()))
a=[]
for i in range(n):
	a.append([int(j) for j in input().split()])
b = []
for i in range(m):
	b.append(int(input()))
for i in range(n):
	s = 0
	for j in range(m):
		s += a[i][j] * b[j]
	print(s)

Buggy python submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
a=[]
for i in range(n):
	a.append([int(j) for j in input().split()])
b = []
for i in range(m)
	b.append(int(input()))
for j in range(n):
	s = 0
	for j in range(m):
		s += a[i][j] * b[j]
	print(s)
	


Fixed submission:
n, m = list(map(int, input().split()))
a=[]
for i in range(n):
	a.append([int(j) for j in input().split()])
b = []
for i in range(m):
	b.append(int(input()))
for i in range(n):
	s = 0
	for j in range(m):
		s += a[i][j] * b[j]
	print(s)
Buggy python submission (verdict: Runtime Error):
s = input()
for i in range(int(input())):
	c = list(map(str, input().split()))
	a, b = int(c[1]), int(c[2])
	if c[0] == "print":
		print(s[a:b+1])
	elif c[0] == " reverse":
		s = s[:a] + s[a:b+1][::-1] + s[b+1:]
	else:
		s = s[:a] + c[3] + c[b+1:]
		


Fixed submission:
s = input()
for _ in range(int(input())):
	o = list(map(str, input().split()))
	a = int(o[1])
	b = int(o[2])
	if o[0] == "print":
		print(s[a:b+1])
	elif o[0] == "reverse":
		s = s[:a] + s[a:b+1][::-1] + s[b+1:]
	else:
		s = s[:a] + o[3] + s[b+1:]
Buggy python submission (verdict: Runtime Error):
def printing(m, G, cnt, A):
    print(m)
    for i in range(len(G)):
        if i != len(G) - 1:
            print(G[i], end=' ')
        else:
            print(G[i])

    print(cnt)
    for i in A:
        print(i)

def insertionSort(A, n, g, 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 = j - g
            cnt += 1
        A[j+g] = v
    return cnt


def shellSort(A, n, cnt):

    m = 2
    G = [4, 1]
    for i in range(0, m):
        cnt = insertionSort(A, n, G[i], cnt)

    printing(m, G, cnt, A)


N = int(input())
inputList = list(map(int, input().split()))

cnt = 0
shellSort(inputList, N, cnt)


Fixed submission:
def printing(m, G, cnt, A):
    print(m)
    for i in range(len(G)):
        if i != len(G) - 1:
            print(G[i], end=' ')
        else:
            print(G[i])

    print(cnt)
    for i in A:
        print(i)

def insertionSort(A, n, g, 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 = j - g
            cnt += 1
        A[j+g] = v
    return cnt


def shellSort(A, n, cnt):

    m = 0
    G = [1]
    while True:
        formulate = 3 * G[m] + 1
        if N > formulate:
            G.append(formulate)
        else:
            break
        m += 1

    for i in range(len(G) // 2):
        G[i], G[-1 - i] = G[-1 - i], G[i]

    for i in range(m + 1):
        cnt = insertionSort(A, n, G[i], cnt)

    printing(m + 1, G, cnt, A)


N = int(input())
inputList = []
for i in range(N):
    inputList.append(int(input()))

# inputList = list(map(int, '''5
# 5 1 4 3 2'''.split()))
# N = inputList.pop(0)

cnt = 0
shellSort(inputList, N, cnt)