Harryxun/stf_run huggingface dataset:
line = input().split()
object_ = input()

N = int(line[0])
A = int(line[1])-1
B = int(line[2])-1
C = int(line[3])-1
D = int(line[4])-1

placing_objects = [True if s == '#' else False for s in list(object_)]

def main():
    if (A < B and C < D) or (A > B and C > D):
        for i in range(N-1):
            if placing_objects[i] and placing_objects[i+1]:
                print('No')
                return
        print('Yes')
        return
    else:
        possible_trans = False
        trans_index = []
        for i in range(N-1):
            if placing_objects[i] and placing_objects[i+1]:
                print('No')
                return
            if i < N-1 and (not placing_objects[i]) and (not placing_objects[i+1]) and (not placing_objects[i+2]):
                possible_trans = True
                trans_index.append(i+1)
        if not possible_trans:
            if C < D:
                if placing_objects[C-1] or placing_objects[C+1]:
                    print('No')
                    return
            else:
                if placing_objects[D-1] or placing_objects[D+1]:
                    print('No')
                    return
        else:
            if A > B:
                if A > max(trans_index):
                    print('No')
                    return
            else:
                if B > max(trans_index) or D < min(trans_index):
                    print('No')
                    return
        print('Yes')
        
main()

### FIXED CODE ###

line = input().split()
object_ = input()

N = int(line[0])
A = int(line[1])-1
B = int(line[2])-1
C = int(line[3])-1
D = int(line[4])-1

placing_objects = [True if s == '#' else False for s in list(object_)]

def main():
    if (A < B and C < D) or (A > B and C > D):
        for i in range(N-1):
            if placing_objects[i] and placing_objects[i+1] and i > A and i < max(C, D):
                print('No')
                return
        print('Yes')
        return
    else:
        possible_trans = False
        trans_index = []
        for i in range(N-1):
            if placing_objects[i] and placing_objects[i+1] and i > A and i < max(C, D):
                print('No')
                return
            if i < N-2 and (not placing_objects[i]) and (not placing_objects[i+1]) and (not placing_objects[i+2]):
                possible_trans = True
                trans_index.append(i+1)
        if not possible_trans:
            if C < D:
                if placing_objects[C-1] or placing_objects[C+1]:
                    print('No')
                    return
            else:
                if placing_objects[D-1] or placing_objects[D+1]:
                    print('No')
                    return
        else:
            if A > B:
                if A > max(trans_index):
                    print('No')
                    return
            else:
                if B > max(trans_index) or D < min(trans_index):
                    print('No')
                    return
        print('Yes')
        
main()
x=input()
x.solt()
if x=="abc":
	print("YES")
else:
	print("NO")


### FIXED CODE ###

print("Yes" if len(set(input())) == 3 else "No")
S = input()
max = 0
i = 0
m = 0
while(i != len(S)):
  if S[i] == "R":
    m += 1
  
  else:
    max = max(max,m)
    m = 0
    break
  i += 1

print(max)

### FIXED CODE ###

s = input()
count = 0
ans = 0

for i in range(len(s)):
  if(s[i] == "R"):
    count += 1
  else:
    ans = max(count, ans)
    count = 0
ans = max(count, ans)
print(ans)
N = int(input())
S = input()
cnt = 0

for i in range(N-1):
	if S[i] = S[i+1]:
      	cnt += 1

ret = N - cnt

print(ret)


### FIXED CODE ###

N = int(input())
S = input()
cnt = 0

for i in range(N-1):
  if S[i] == S[i+1]:
    cnt += 1
    
print(N - cnt)
import math
x,y = map(int,input().split())
print((x * y) // math.gcd(x, y))

### FIXED CODE ###

from fractions import gcd
x,y = map(int,input().split())
print((x * y) // gcd(x, y))
N = int(input())
a = list(map(int, input().split()))
A = [0 for i in range(8)]
b = 0
ans1 = 0
for i in range(N):
  if a[i] < 400:
    if A[0] == 0:
      A[0] = 1
      ans1 += 1
  elif a[i] < 800:
    if A[1] == 0:
      A[1] = 1
      ans1 += 1
  elif a[i] < 1200:
    if A[2] == 0:
      A[2] = 1
      ans1 += 1
  elif a[i] < 1600:
    if A[3] == 0:
      A[3] = 1
      ans1 += 1
  elif a[i] < 2000:
    if A[4] == 0:
      A[4] = 1
      ans1 += 1
  elif a[i] < 2400:
    if A[5] == 0:
      A[5] = 1
      ans1 += 1
  elif a[i] < 2800:
    if A[6] == 0:
      A[6] = 1
      ans1 += 1
  elif a[i] < 3200:
    if A[7] == 0:
      A[7] = 1
      ans += 1
  elif a[i] >= 3200:
    b += 1
ans2 = ans1 + b
if ans1 < 1:
  ans1 = 1
  ans2 = b
if ans2 > 8:
  ans2 = 8
print(ans1, ans2, sep=' ')

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = [0 for i in range(8)]
a = 0
for i in range(N):
  if A[i] < 400:
    B[0] = 1
  elif A[i] < 800:
    B[1] = 1
  elif A[i] < 1200:
    B[2] = 1
  elif A[i] < 1600:
    B[3] = 1
  elif A[i] < 2000:
    B[4] = 1
  elif A[i] < 2400:
    B[5] = 1
  elif A[i] < 2800:
    B[6] = 1
  elif A[i] < 3200:
    B[7] = 1
  else:
    a += 1
b = sum(B)
m = b
M = b + a
if b == 0:
  m = 1
print(m, M, sep=' ')
S = input()
if S = "AAA" or S = "BBB":
    print("No")
else:
    print("Yes")

### FIXED CODE ###

S = input()
if S == "AAA" or S == "BBB":
    print("No")
else:
    print("Yes")
n = int(input())
a_list = sorted(map(int, input().split()),reverse=True)

if n <= 2:
  a_list.pop(-1)
  print(sum(a_list))
else:
  ans = 0
  ans += a_list.pop(0)
  cnt = 2
  while 1:
    if cnt == n:
      break
    if n - cnt >= 2:
      ans += a_list.pop(0) * 2
      cnt += 2
    else:
      ans += a_list.pop(0) * 1
      cnt += 1
      
print(ans)

### FIXED CODE ###

n = int(input())
a_list = sorted(map(int, input().split()),reverse=True)

ans = 0
ans += a_list.pop(0)
cnt = 2
times_2 = 0
times_1 = 0
while 1:
  if cnt == n:
    break
  if n - cnt >= 2:
    cnt += 2
    times_2 += 1
  else:
    cnt += 1
    times_1 += 1
      
ind = 0
for i in range(times_2):
  ans += 2 * a_list[i]
  ind += 1
  
for i in range(times_1):
  ans += a_list[ind + i]

print(ans)
def isPrime(num):
    if num == 2: return 1
    if num < 2 or num&1 == 0: return 0
    if pow(2, num-1, num) == 1: return 1

n = input()
s = 0
for i in xrange(n):
    s += isPrime(input())

print s

### FIXED CODE ###

def isPrime(num):
    if num == 2: return 1
    if num < 2 or num&1 == 0: return 0
    if pow(2, num-1, num) == 1: return 1
    return 0

n = input()
s = 0
for i in xrange(n):
    s += isPrime(input())

print s
#!/usr/bin/env python
x = int(input())
y = int(input())
if x % y  == 0 or x > 10**18:
	print(-1)
else:
	print(x)
	 


### FIXED CODE ###

#!/usr/bin/env python
x,y = map(int,input().split())
if x % y  == 0 or x > 10**18:
	print(-1)
else:
	print(x)
N, *A = [int(_) for _ in open(0).read().split()]
sumB = max(0, sum(A) - N * (N - 1))
while True:
    B = [0 - (-(a + x + 1 - N)) // (N + 1) for a in A]
    if sumB == sum(B):
        break
    sumB += 1
print(sumB)


### FIXED CODE ###

N = int(input())
A = sorted([int(_) for _ in input().split()])
#B[i]回の操作をすると全項N-1以下になる
#A[i]-N*B[i]+sum(B)-B[i]<=N-1 が全iで成り立つ
#B[i]=0-(-(a+x+1-N))//(N+1)

def check(x):
    b = [0 - (-(a + x + 1 - N)) // (N + 1) for a in A]
    return sum(b) == x

p = max(0, sum(A) - (N - 1) * N)
while True:
    q = check(p)
    if q:
        break
    p += 1
print(p)
import itertools
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
M = 1000000007
N = int(input())
left = list(map(int, input().split()))

counter = Counter(left)


def dp(t, ns):
    cached = t.get(ns)
    if cached is not None:
        return cached
    remaining = sum(ns)
    last_cnt = left[remaining - 1] + 1
    n1, n2, n3 = ns
    res = 0
    if last_cnt == n1:
        res += dp(t, tuple(sorted([n1 - 1, n2, n3])))
        res %= M
    if last_cnt == n2:
        res += dp(t, tuple(sorted([n1, n2 - 1, n3])))
        res %= M
    if last_cnt == n3:
        res += dp(t, tuple(sorted([n1, n2, n3 - 1])))
        res %= M
    t[ns] = res
    return res


def solve():
    h = [0, 0, 0]
    for i in range(N):
        k = counter[i]
        if k == 3:
            h[0] = h[1] = h[2] = i + 1
        elif k == 2:
            h[0] = h[1] = i + 1
        elif k == 1:
            h[0] = i + 1
        else:
            break
    t = dict()
    t[0, 0, 0] = 1
    res = dp(t, tuple(sorted(h))) % M
    return (res * len(set(itertools.permutations(h)))) % M


print(solve())


### FIXED CODE ###

import itertools
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 9)
M = 1000000007
N = int(sys.stdin.readline())
left = list(map(int, sys.stdin.read().split()))
counter = Counter(left)


def dp(t, ns):
    cached = t.get(ns)
    if cached is not None:
        return cached
    remaining = sum(ns)
    assert remaining > 0
    last_cnt = left[remaining - 1] + 1
    n1, n2, n3 = ns
    res = 0
    if last_cnt == n1:
        res += dp(t, tuple(sorted([n1 - 1, n2, n3])))
        res %= M
    if last_cnt == n2:
        res += dp(t, tuple(sorted([n1, n2 - 1, n3])))
        res %= M
    if last_cnt == n3:
        res += dp(t, tuple(sorted([n1, n2, n3 - 1])))
        res %= M
    # print(f"{remaining}: ({n1},{n2},{n3}) => {res}")
    t[ns] = res
    return res


def solve():
    h = [0, 0, 0]
    for i in range(N):
        k = counter[i]
        if k == 3:
            h[0] = h[1] = h[2] = i + 1
        elif k == 2:
            h[0] = h[1] = i + 1
        elif k == 1:
            h[0] = i + 1
        else:
            break
    if sum(h) != N:
        return 0
    t = dict()
    t[0, 0, 0] = 1
    res = dp(t, tuple(sorted(h)))
    return (res * len(set(itertools.permutations(h)))) % M


print(solve())
N = int(input())
A = [input() for _ in range(N)]
d = defaultdict(int)
for a in A:
  d[a] += 1

  li = sorted(d.items())
  l = sorted(li, key = itemgetter(0), reverse=True)
  max_key = l[0][0]

  for k, v in li:
    if k == max_key:
      print(k)
      else:
        continue

### FIXED CODE ###

def solve():
    import itertools
    from operator import itemgetter

    N = int(input())
    B = [input() for _ in range(N)]
    B.sort()

    l = []
    gr = itertools.groupby(B)
    max_key = 0
    for key, group in gr:
        length = len(list(group))
        l.append((length, key))
        if length > max_key:
            max_key = length

    l.sort(key = itemgetter(0), reverse=True)

    key = l[0][0]
    for k, v in l:
        if key == k:
            print(v)
        else:
            break

solve()
a, b = list(map(int, input()))
print((a-1)*(b-1))

### FIXED CODE ###

a, b = list(map(int, input().split()))
print((a-1)*(b-1))
import statistics
while True:
  n = input()
  if n == '0': break
  print(statistics.stdev(map(int, input().split())))

### FIXED CODE ###

import math

while True:
    n = int(input())
    if n == 0:
        break
    points = list(map(int, input().split()))

    m = sum(points) / n
    variance = sum(map(lambda x: (x - m) ** 2, points)) / n
    standard_deviation = math.sqrt(variance)
    print(standard_deviation)
import math
S = int(input())
L = 10**9

def search():
    p = int(math.sqrt(S))
    q = p
    i = 0
    while p*q < S:
        if i % 2 == 0 or q == L-1: p += 1
        if i % 2 == 1 or p == L-1: q += 1
        i += 1
    if S%2 == 0 and (p*q)%2 == 1:
        q += 1
    elif S%2 == 1 and (p*q)%2 == 0:
        if p%2 == 0: p += 1
        if q%2 == 0: q += 1
    target = (p*q - S) // 2
    divisor = 2
    assert p < L
    assert q < L
    return (0, 0, p, divisor, target, q)

print(*search())

### FIXED CODE ###

import math
S = int(input())
L = 10**9

def search():
    p = int(math.sqrt(S))
    q = p
    i = 0
    while p*q < S:
        if i % 2 == 0 or q == L: p += 1
        if i % 2 == 1 or p == L: q += 1
        i += 1
    assert p <= L and q <= L
    target = p*q - S
    divisor = 1
    #assert target < L
    return (0, 0, p, divisor, target, q)

print(*search())
N, M, K = map(int, input().split())
mod = 10**9+7
ans = 0
def combination(a,b, mod):
    b = min(b, a-b)
    ans = 1
    for i in range(0,b):
        ans *= (a-i)/(i+1) % mod
    return int(ans)
for d in range(1,N):
    ans += d*(N-d)*M**2 % mod
for d in range(1,M):
    ans += d*(M-d)*N**2 % mod
ans *= combination(N*M-2, K-2, mod) % mod
print(ans)

### FIXED CODE ###

N, M, K = map(int, input().split())
ans=0
mod = 10**9+7 #出力の制限
max = 2*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, max + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
for d in range(1,N):
    ans += d*(N-d)*M**2 % mod
for d in range(1,M):
    ans += d*(M-d)*N**2 % mod
ans = ans*cmb(N*M-2, K-2, mod) % mod
print(ans)
N=int(input())
A=[]
pairs=[]
for i in range(N):
    a=int(input())
    A.append(a)
    pair=[]
    for j in range(a):
        x,y=map(int,input().split())
        pair.append([x-1,y])
    pairs.append(pair)
print(pairs)
def judge(bit):
    for i in range(N):
        if bit&(1<<i)==False: #決め打ち時に不親切の場合
            continue
        for j in range(A[i]): #親切な人の発言検証
            tmpx=pairs[j][0][0]
            tmpy=pairs[j][0][1]
            if tmpy==1  and (bit&(1<<tmpx)==False):
                return False
            if tmpy==0 and (bit&(1<<tmpx)):
                return False
    return True

ans=0
for bit in range((1<<N)):
    if judge(bit)==True:
        count=0
        for i in range(N):
            if bit&(1<<i):
               count+=1
        ans=max(ans,count)

print(ans)

### FIXED CODE ###

N=int(input())
A=[]
pairs=[]
for i in range(N):
    a=int(input())
    A.append(a)
    pair=[]
    for j in range(a):
        x,y=map(int,input().split())
        pair.append([x-1,y])
    pairs.append(pair)

def judge(bit):
    for i in range(N):
        if bit&(1<<i)==False: #決め打ち時に不親切の場合
            continue
        for j in range(A[i]): #親切な人の発言検証
            tmpx=pairs[i][j][0]
            tmpy=pairs[i][j][1]
            if tmpy==1  and (bit&(1<<tmpx)==False):
                return False
            if tmpy==0 and (bit&(1<<tmpx)):
                return False
    return True

ans=0
for bit in range((1<<N)):
    if judge(bit):
        count=0
        for i in range(N):
            if (bit&(1<<i)):
               count+=1
        ans=max(ans,count)

print(ans)
n=int(input())
b=list(map(int,input().split()))
a=[]
ans=b[0]
a.append(ans)
for i in range(1,n-1):
    if(b[i] < ans):
        a.append(b[i])
    else:
        a.append(ans)
    ans=b[i]
a.append(b[i])
print(sum(a))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=0
count=-1
acount=0
for i in a:
    ans+=b[i-1]
    if(acount <= len(a)-2):
        if(a[acount+1]==i+1):
            #print('cappned')
            ans+=c[i-1]
    count=i
    acount+=1
print(ans)
n=int(input())
L=[0 for i in range(n)]
L[0]=2 ; L[1]=1
for i in range(2,n):
  L[i]=L[i-1]+L[i-2]
print(L[n-1])

### FIXED CODE ###

A=[2,1]
n=int(input())
for i in range(n-1):
  A.append(A[i]+A[i+1])
print(A[-1])
import sys
import numpy as np


def input():
    return sys.stdin.readline()[:-1]

N = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def func1(lst, value):
    return [i for i, x in enumerate(lst) if x <= value]


ans_ = np.array(factorization(N))
nums = []
index_list = []

ans = 0
for i in range(1, 100):
	ans += i
	index_list.append(ans)

for a in ans_:
	#nums.append(int(format(a[1], 'b')))
	nums.append(a[1])
	
ans = 0
for i in nums:
	index = func1(index_list, i)
	#print(max(index)+1)
	ans += max(index)+1
	
print(ans)


### FIXED CODE ###

import sys

def input():
    return sys.stdin.readline()[:-1]

N = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def func1(lst, value):
    return [i for i, x in enumerate(lst) if x <= value]

if N == 1:
	print(0)
else:
	
	ans_ = factorization(N)
	nums = []
	index_list = []
	
	ans = 0
	for i in range(1, 100):
		ans += i
		index_list.append(ans)
		
	for a in ans_:
		#nums.append(int(format(a[1], 'b')))
		nums.append(a[1])
		
		#print(nums)
			
	ans = 0
	for i in nums:
		index = func1(index_list, i)
		#print(max(index)+1)
		ans += max(index)+1
	
	print(ans)
a = input().split()

b = len(a)
c = b + 1
i = 0
while i < c:
    c = a[i]
    if c == 7:
        print('Yes')
        break
    elif c==a:
          print('No')
        
    i += 1


### FIXED CODE ###

a = input()
if '7' in a:
   print('Yes')
else:
   print('No')
import sys
N,M = map(int,input().split())
s = [list(map(int,input().split())) for i in range(M)]
ans = 0
ans_list = [ 0 for i in range(M)]

if M == 0:
    if N == 1:
        print('0')
    else:
        print(-1)
    sys.exit()
import sys
N,M = map(int,input().split())
s = [list(map(int,input().split())) for i in range(M)]
ans = 0
ans_list = [ 0 for i in range(M)]

if M == 0:
    if N == 1:
        print('0')
    else:
        print(-1)
    sys.exit()

for i in range(M):
    ans_list[s[i][0]-1] = s[i][1]

for i in range(M):
    ans = ans * 10 + ans_list[i]

if len(str(ans)) == N:
    print(ans)
else:
    print('-1')
for i in range(M):
    ans_list[s[i][0]-1] = s[i][1]

for i in range(M):
    ans = ans * 10 + ans_list[i]

if len(str(ans)) == N:
    print(ans)
else:
    print('-1')

### FIXED CODE ###

import sys
N,M = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(M)]

ans = ['-1'] * N

for i in range(M):
    if ans[sc[i][0]-1] == sc[i][1]:
        continue
    elif ans[sc[i][0]-1] == '-1':
        ans[sc[i][0]-1] = sc[i][1]
    else:
        print('-1')
        sys.exit()

if N >= 2:
    if ans[0] == '-1':
        ans[0] = 1
    elif ans[0] == 0:
        print('-1')
        sys.exit()
else:
    if ans[0] == '-1':
        print(0)
        sys.exit()

for i in range(N):
    if ans[i] == '-1':
        ans[i] = 0

real = 0
for i in ans:
    real = real * 10 + i

print(real)
while True:
    N = int(input())
    if N==0:break
    dataset = input()
    mens = ["" for _ in range(N)]
    i = 0
    p = ""
    while dataset:
        if i == N: i = 0
        card, dataset = dataset[0], dataset[1:]
        if card == "M":
            mens[i] += card
        elif card == "S":
            p += card + mens[i]
            mens[i] = ""
        else:
            mens[i] += card + p
            p = ""
        i += 1
    print(*[len(s) for s in sorted(mens)], len(p))

### FIXED CODE ###

while True:
    N = int(input())
    if N==0:break
    dataset = input()
    mens = ["" for _ in range(N)]
    i = 0
    p = ""
    while dataset:
        if i == N: i = 0
        card, dataset = dataset[0], dataset[1:]
        if card == "M":
            mens[i] += card
        elif card == "S":
            p += card + mens[i]
            mens[i] = ""
        else:
            mens[i] += card + p
            p = ""
        i += 1
    print(' '.join(map(str, sorted([len(m) for m in mens]))), len(p))
import math
# a,b =[int(i) for i in input().split()]

r=int(input())
#r=2

A=[math.pi*r**2,2*math.pi*r]
print("{0:.6f} {1:.6f}".format(A[0],A[1]))

### FIXED CODE ###

#import math
# a,b =[int(i) for i in input().split()]

r=float(input())
#r=2
pi=3.141592653589793
A=[pi*r**2,2*pi*r]
print("{0:.5f} {1:.5f}".format(A[0],A[1]))
a, b = map(int, input().split())
ans = 0
for i in range(1,10):
  for j in range(0,10):
    for k in range(0.10):
  x = 10000*i + 1000*j + 100*k + 10*j + i
  if a <= x <= b:
    ans += 1
print(ans)

### FIXED CODE ###

a, b = map(int, input().split())
ans = 0
import itertools
for i,j,k in itertools.product(range(0,10), repeat=3):
  if i == 0:
    continue
  x = 10000*i + 1000*j + 100*k + 10*j + i
  if a <= x <= b:
    ans += 1
print(ans)
s=set(input())
a='abcdefghijklmnopqrstuvwxyz'
b=set()
for i in range(26):
    b.append(str(a[i]))
if s==b:
    print('None')
else:
    print(b-s)


### FIXED CODE ###

s=set(list(input()))
a=set(list('abcdefghijklmnopqrstuvwxyz'))

if s==a:
    print('None')
else:
    b=sorted(list(a-s))
    print(str(b[0]))
import fractions 

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

ans = 0
for i in range(N):
  if i == 0:
    ans = A[0]
    continue

  ans = gcd(ans,A[i])
  
print(ans)

### FIXED CODE ###

import fractions 

N = int(input())
A = list(map(int,input().split()))
 
ans = 0
for i in range(N):
  if i == 0:
    ans = A[0]
    continue
 
  ans = fractions.gcd(ans,A[i])
  
print(ans)
N,K = map(int,input().split())
int H = 0
while True:
  if (N > K):
    H = N-K
  else:
    H = K - N
  if (H>N):
    break
  else:
    N = H
print(N)
  

### FIXED CODE ###

N,K = map(int,input().split())
H = 0
while True:
  if (N > K):
    H = N%K
  else:
    H = K-N
  if (H>N):
    break
  else:
    N = H
print(N)
def insertionSort(arr, g):
    cnt = 0
    for i in range(g, len(arr)):
        tmp = arr[i]
        j = i - g
        while(j >= 0 and arr[j] > tmp):
            arr[j + g] = arr[j]
            j -= g
            cnt += 1
        arr[j + 1] = tmp
    return cnt


def shellSort(arr):
    cnt = 0
    g = []
    h = 0
    while h <= len(arr) / 9:
        h = 3 * h + 1
        g.append(h)
    g = g[::-1]

    for i in range(0, m):
        cnt += insertionSort(arr, g[i])
    return (cnt, g)


N = int(input())
arr = [int(input()) for i in range(N)]

cnt, g = shellSort(arr)
print(len(g))
print(' '.join(map(str, g)))
print(cnt)
print('\n'.join(map(str, arr)))



### FIXED CODE ###

def insertionSort(arr, N, g):
    cnt = 0
    for i in range(g, N):
        tmp = arr[i]
        j = i - g
        while(j >= 0 and arr[j] > tmp):
            arr[j + g] = arr[j]
            j -= g
            cnt += 1
        arr[j + g] = tmp
    return cnt


def shellSort(arr, N):
    G = []
    h = 0
    m = 0
    while h <= N / 9:
        h = 3 * h + 1
        G.append(h)
        m += 1
    G = G[::-1]

    cnt = sum([insertionSort(arr, N, g) for g in G])
    return (cnt, G)


N = int(input())
arr = [int(input()) for i in range(N)]

(cnt, G) = shellSort(arr, N)
print(len(G))
print(' '.join(map(str, G)))
print(cnt)
print('\n'.join(map(str, arr)))