Harryxun/stf_run huggingface dataset:
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""
n=  int(sys.stdin.readline())
h=  list(map(int, sys.stdin.readline().split()))

tmp=0
c=0
for i in range(n-1):
    if h[i] >= h[i+1]:
        c+=1
        ans=c
    else:
        if tmp <= c:
            ans = c
            tmp = c
            c=0
        else:
            c=0
            ans = tmp
print(ans)

### FIXED CODE ###

import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""
n =  int(sys.stdin.readline())
h =  list(map(int, sys.stdin.readline().split()))

tmp=0
c=0
if n==1:
    print(0)
else:
    for i in range(n-1):
        if h[i] >= h[i+1]:
            c+=1
        else:
            if tmp < c:
                tmp = c
            else:
                ans = tmp
            c=0
        ans = max(c,tmp)
    print(ans)
def resolve():
    X, N = map(int, input().split())
    P = []
    for i in range(N):
        p = int(input())
        P.append(p)
    plus = 1
    while True:
        if X in P:
            if plus%2 == 1:
                X -= plus
                plus +=1
            else:
                X += plus
                plus += 1
        else:
            print(X)
            exit()
resolve()

### FIXED CODE ###

def resolve():
    X, N = map(int, input().split())
    if N != 0:
        P = list(map(int, input().split()))
        S = []
        for _ in range(0, 102):
            if _ in P:
                continue
            else:
                S.append(_)
        if X in S:
            print(X)
        else:
            for i in range(1, 102):
                if X-i in S:
                    print(X-i)
                    exit()
                elif X+i in S:
                    print(X+i)
                    exit()
    else:
        print(X)
resolve()
a,b = map(int,input())
if a==b:
  print(2*b)
else:
  x = max(a,b)
  print(2*x-1)

### FIXED CODE ###

a,b = map(int,input().split())
if a==b:
  print(2*b)
else:
  x = max(a,b)
  print(2*x-1)
from math import floor
a,b,n=map(int,input().split())
if(n<b):
  print(floor((a*n)/b))
else:
  if(n%b<(n/2)):
    for i in range(0,(n%b)+1):
      print(floor((a*(n-1-i))/b)-(a*floor((n-1-i)/b)))
  else:
    print(floor((a*(n))/b)-(a*floor((n)/b)))


### FIXED CODE ###

k=int(input())
a,b=map(int,input().split())
c=0
for i in range(a,b+1):
  if(i%k==0):
    c=c+1
if(c==0):
  print("NG")
else:
  print("OK")
N = list(map(int,input().split()))
M = 10**9 + 7
red = N[0] - N[1]
x = red+1
print(x)
for i in range(2,N[1]+1):
    x *= (red+2-i)*(N[1]-i+1)/(i*(i-1))
    print(int(x%M))

### FIXED CODE ###

# -*- coding:utf-8 -*-

def cmb(n, r):
    if n == 0 or r == 0:
        return 1
    if n < r:
        return 0
    a = b = 1
    r = min(n-r,r)
    for i in range(1, r + 1):
        a *= i
    for i in range(n-r+1,n+1):
        b *= i
    return b//a

N = list(map(int,input().split()))
M = 10**9 + 7
red = N[0]-N[1]
for i in range(1,N[1]+1):
    x = cmb(red + 1, i) * cmb(N[1] - 1,i-1)
    print(x%M)
import statistics

N = int(input())
A = [int(i) for i in input().split()]
B = [A[i] - (i+1) for i in range(N)]
b = statistics.median(B)
sum = 0
for i in range(N):
    sum += abs(B[i] - b)
print(int(sum))

### FIXED CODE ###

import statistics

N = int(input())
A = [int(i) for i in input().split()]
B = [(A[i] - (i+1)) for i in range(N)]
b = statistics.median(B)
sum = 0
for i in range(N):
    sum += abs(B[i] - b)
print(int(sum))
A, B = map(int, input().split())
G1 = [['#'] * 100 for i in range(50)]
G2 = [['.'] * 100 for i in range(50)]

A, B = A - 1, B - 1

h, w = 0, 0
for a in range(A):
    if w > 99:
        h += 1
    G1[h][w] = '.'
    w += 2

h, w = 1, 0
for b in range(B):
    if w > 99:
        h += 1
    G2[h][w] = '#'
    w += 2


print(100, 100)
for g in G1:
    print(''.join(g))
for g in G2:
    print(''.join(g))


### FIXED CODE ###

A, B = map(int, input().split())
white = [["#"] * 100 for i in range(50)]
black = [["."] * 100 for i in range(50)]
A, B = A-1, B-1

row = 0
line = 0
for i in range(A):
    white[line][row] = "."
    row += 2
    if row >= 100:
        row = 0
        line += 2

row = 0
line = 1
for i in range(B):
    black[line][row] = "#"
    row += 2
    if row >= 100:
        row = 0
        line += 2

ans = white + black
print(100, 100)
for a in ans:
    print("".join(a))
import fractions
import sys

input = sys.stdin.readline

mp = 1000###max prime
mod = 10 ** 9 + 7
def prime_factorize(n):
    a = [0] * mp
    while n % 2 == 0:
        a[2] += 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a[f] += 1
            n //= f
        else:
            f += 2
    if n != 1:
        a[n] += 1
    return a

def lcm(x,y):
    return x * y // fractions.gcd(x,y)

def fact_mul(x,y):
    ret = [0] * mp
    for i in range(mp):
        ret[i] = x[i] + y[i]
    return ret

def fact_div(x,y):
    ret = [0] * mp
    for i in range(mp):
        ret[i] = x[i] - y[i]
    return ret

def cal_mod(x):
    ret = 1
    for i in range(mp):
        ret *= (i**x[i]) % mod
        ret %= mod
    return ret


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

A_fact = [0] * N###Aの各要素の素因数分解
for i in range(N):
    A_fact[i] = prime_factorize(A[i])
#print(A_fact[0][0:12])

l_fact = A_fact[0][:]

for i in range(1,N):
    for j in range(1,mp):
        l_fact[j] = max(A_fact[i][j],l_fact[j])

B0_fact = [0] * mp


for i in range(mp):
    B0_fact[i] = max(0,l_fact[i]-A_fact[0][i])

ans = cal_mod(B0_fact)
#print(A_fact[0][0:12])
#print(B0_fact[0:12])
#print(cal_mod(l_fact))
#print(ans)
#print(A_fact)
#print(B0_fact)
for i in range(1,N):
    Bi = fact_div(fact_mul(A_fact[0],B0_fact),A_fact[i])
    ans += cal_mod(Bi)
    ans %= mod

print(ans)

### FIXED CODE ###

###提出 #10048385

n = int(input())
a = list(map(int, input().split()))
from fractions import gcd
from functools import reduce
def lcm(x,y):
  return (x*y)//gcd(x,y)
mod = 10**9+7
l = reduce(lcm, a) % mod
ans = 0
for i in range(n):
  ans += l * pow(a[i], mod - 2, mod)
  ans %= mod
print(ans)

#頭良すぎて草
from collections import defaultdict
N, M = map(int, input().split())
A = [int(i) for i in input().split()]

dic = defaultdict(int)
for i in range(M):
    b, c = map(int, input().split())
    dic[c] += b
for x in A:
    dic[x] += 1
dic = sorted(dic.items(), key=lambda x:x[0], reverse=True)
cur = 0
ans = 0
for x, y in dic.items():
    cur += y
    if cur > len(A):
        print(ans + x*(y - (cur - len(A)))
        sys.exit()
    else:
        ans += x*y

### FIXED CODE ###

from collections import defaultdict
import sys
N, M = map(int, input().split())
A = [int(i) for i in input().split()]

dic = defaultdict(int)
for i in range(M):
    b, c = map(int, input().split())
    dic[c] += b
for x in A:
    dic[x] += 1
dic = sorted(dic.items(), key=lambda x:x[0], reverse=True)
cur = 0
ans = 0
for x, y in dic:
    cur += y
    if cur > len(A):
        print(ans + x*(y - (cur - len(A))))
        sys.exit()
    else:
        ans += x*y
import collections
N=int(input())
S=[input() for i in range(N)]
c=collections.Counter(S)
most=c.most_comon()[0][1]
if len(c)==1:
  print(c.most_common()[0][0])
else:
  for i in range(len(c)):
    print(c.most_common()[i][0])
    if c.most_common()[i+1][1] !=most:
      break


### FIXED CODE ###

import collections
N = int(input())
s = [input() for i in range(N)]
 
counter = collections.Counter(s)
count = counter.most_common()
 
most = count[0][1]
 
c =[]
for i in range(len(count)):
    if count[i][1] == most:
        c.append(count[i][0])
 
c.sort()
 
for i in range(len(c)):
    print(c[i])
import math

def comb(n,r):
	return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

N, K = map(int, input().split())

for i in range(1,K+1):
	print(comb(N-K+1,i)*comb(K-1,i-1)%1000000007)

### FIXED CODE ###

from math import factorial
N, K = map(int, input().split())
mod = 10**9 + 7
def combination(n, r):
	if n >= r:
		return int(factorial(n) // (factorial(r) * factorial(n - r)))
	else:
		return 0

for i in range(1, K+1):
	print(combination(N-K+1, i) * combination(K-1, i-1)%mod)
N = int(input())
A = list(map(int, input().split()))

number = 0
MOD = 1000000007

for i in range(N-1):
    for j in range(i+1, N):
        number += A[i]*A[j]


if number > MOD:
    print(number%MOD)
else:
    print(number)


### FIXED CODE ###

D, T, S = map(int, input().split())

a = T * S - D
if a >= 0:
    print('Yes')
else:
    print('No')
a, b, c = map(int, input().split())
print(sum(a, b, c) - max(a, b, c))

### FIXED CODE ###

a, b, c = map(int, input().split())
print(a+b+c - max(a, b, c))
s = input()
l = len(s)
ans = 0
for i in range(2**(l-1)):
    e = ""
    for j in range(l):
        if ((i >> j) & 1):
            e += s[j] + "+"
        else:
            e += s[j] + "-"
    if eval(e) == 7:
        print(e)
        break

### FIXED CODE ###

s = input()
l = len(s)
ans = 0
for i in range(2**(l-1)):
    e = ""
    for j in range(l):
        if ((i >> j) & 1):
            e += s[j] + "+"
        else:
            e += s[j] + "-"
    if eval(e[:-1]) == 7:
        print(e[:-1]+'=7')
        break
# a, b = map(int, input().split())
a = int(input())
b = int(input())

if b == 'H':
  print('H') if a == 'H' else print('D')
else:
  print('D') if a == 'H' else print('H')

### FIXED CODE ###

a, b = input().split()
print('H') if a == b else print('D')
x = input()
a = []
for i in range(N):
    a.append(input())
    print('case{}:{}'.format(x,a))

### FIXED CODE ###

l = []
y = 1
while True:
    x = int(input())
    if x == 0:
        break
    l.append(x)
    print('Case {}: {}'.format(y,x))
    y += 1
from decimal import Decimal
A, B = map(input().split())
B = B.replace('.', '')
A = int(A)
B = int(B)

print(int(A*B//100))

### FIXED CODE ###

A, B = input().split()
B = B.replace('.', '')
A = int(A)
B = int(B)

print(int(A*B//100))
a,b,c = map(int, input().split())

if a=b and b=c and a=c:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a,b,c = map(int, input().split())

if a==b and b==c and a==c:
  print('Yes')
else:
  print('No')
N = str(input())

#N = str(14282668646)

count = 0
lenN = len(N)+1
for i in range(0, lenN):
#    t = i
    for j in range(i+5, i+8):
#        print (i, j)
        number = int(str(N[i:j]))
        if number%2019 == 0:
            count +=1
            break


print (count)

### FIXED CODE ###

N, K = map(int, input().split())
sumR = 0
for i in range(K, N+2):
    front = i*(2*N + 2 - i + 1)/2
    rear = i*(i+1)/2
    number = front - rear + 1
#    print (i)
#    print (number)
    sumR += number
print (int(sumR%(1000000007)))
n, m, k = map(int, input().split())

fr = [[] for _ in range(n)]
bl = [[] for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    fr[a-1].append(b-1)
    fr[b-1].append(a-1)
    
for i in range(k):
    c ,d = map(int, input().split())
    bl[c-1].append(d-1)
    bl[d-1].append(c-1)
    

def connectedcomponents():
    visited = []
    cc = []
    for i in range(n):
        visited.append(False)
    for v in range(n):
        if visited[v] == False:
            temp = []
            cc.append(dfs(fr,v,temp,visited))
    return cc
            

def dfs(fr, v, temp, visited):
    visited[v] = True
    temp.append(v)
    for i in fr[v]:
        if visited[i] == False:
            temp = dfs(fr, i, temp, visited)
    return temp

cc = connectedcomponents()

ans = []
for i in range(n):
    for component in cc:
        if i in component:
            recom = [item for item in component if item not in fr[i]]
            recom = [item for item in recom if item not in bl[i]]
            ans.append(len(recom)-1)
print(*ans)

### FIXED CODE ###


from sys import setrecursionlimit 
setrecursionlimit(10**6)

n, m, k = map(int, input().split())

fr = [set() for _ in range(n)]
bl = [set() for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    fr[a-1].add(b-1)
    fr[b-1].add(a-1)
    
for i in range(k):
    c ,d = map(int, input().split())
    bl[c-1].add(d-1)
    bl[d-1].add(c-1)
    

def connectedcomponents():
    visited = []
    cc = [0]*n
    for i in range(n):
        visited.append(False)
    for v in range(n):
        if visited[v] == False:
            temp = set()
            for i in dfs(fr,v,temp,visited):
                cc[i] = dfs(fr,v,temp,visited)
    return cc
            

def dfs(fr, v, temp, visited):
    visited[v] = True
    temp.add(v)
    for i in fr[v]:
        if visited[i] == False:
            temp = dfs(fr, i, temp, visited)
    return temp

cc = connectedcomponents()

ans = []
for i in range(n):
    aa = len(cc[i]) - len(cc[i] & fr[i]) - len(cc[i] & bl[i]) - 1
    ans.append(aa)
print(*ans)
n = int(input())
a = map(int, input()split())
print(max(a)-min(a))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
print(max(a)-min(a))
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	weather := []string{"Sunny","Cloudy","Rainy","Sunny"}
	for i, wthr := range weather{
		if S == wthr {
			fmt.Println(weather[i+1])
			return
		}
	}
}


### FIXED CODE ###

S = input()
weather = ['Sunny', 'Cloudy', 'Rainy']
if S == weather[0]:
    ans = weather[1]
elif S == weather[1]:
    ans = weather[2]
elif S == weather[2]:
    ans = weather[0]
print(ans)
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
def fb(num):
    a,b = 1,0
    for _ in range(num+1):
        a,b = a+b,a
    return b
if m=0:
    print(fb(n)%(10**9+7))
    exit()
if m>1:
    for i in range(m-1):
        if a[i+1]-a[i]==1:
            print(0)
            exit()
c=0
for i in range(m):
    if i==0 and a[0]==1:
        c+=1
    elif i==0:
        c+=fb(a[0]-1)
    else:
        c*=(fb(a[i]-a[i-1]-2)%(10**9+7))
c*=fb(n-a[-1]-1)%(10**9+7)
print(c%(10**9+7))

### FIXED CODE ###

n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
def fb(num):
    a,b = 1,0
    for _ in range(num+1):
        a,b = a+b,a
    return b
if m==0:
    print(fb(n)%(10**9+7))
    exit()
if m>1:
    for i in range(m-1):
        if a[i+1]-a[i]==1:
            print(0)
            exit()
c=0
for i in range(m):
    if i==0 and a[0]==1:
        c+=1
    elif i==0:
        c+=fb(a[0]-1)
    else:
        c*=(fb(a[i]-a[i-1]-2)%(10**9+7))
c*=fb(n-a[-1]-1)%(10**9+7)
print(c%(10**9+7))
N=int(input())
a=[i for i in range(N+1)]
for i in range(N+1):
  if i%3==0 or i%5==0:
    del(a[i])
sum(a)

### FIXED CODE ###

N=int(input())
a=[i for i in range(N+1)]
for i in range(N+1):
  if i%3==0 or i%5==0:
    a[i]=0
print(sum(a))
n,k=map(int,input().split())
A=list(map(int,input().split()))

s=sum(A)
import math
def yakusu(n):
  ans_local=set()
  for i in range(1,int(math.sqrt(n))+1):
    if n%i==0:
      ans_local = ans_local | set([i,n//i]) #setなので平方数でもOK
  return list(ans_local)  #必要に応じてsort

yaku=sorted(yakusu(s), reverse=1)
#print(yaku)
for mod in yaku:
    B=[i%mod for i in A if i%mod!=0]
    B.sort()
    r=[B[0]]*len(B)
    for i in range(len(B)-1):
        r[i+1]= r[i]+B[i+1]
    now=float("INF")
    for i in range(1,len(B)):
        now= min(max(r[i-1], mod*(len(B)-i)-(r[-1]-r[i-1])),now)
    if now<=k:
        print(mod);exit()
    

### FIXED CODE ###

n,k=map(int,input().split())
A=list(map(int,input().split()))

s=sum(A)
import math
def yakusu(n):
  ans_local=set()
  for i in range(1,int(math.sqrt(n))+1):
    if n%i==0:
      ans_local = ans_local | set([i,n//i]) #setなので平方数でもOK
  return list(ans_local)  #必要に応じてsort

yaku=sorted(yakusu(s), reverse=1)
#print(yaku)
for mod in yaku:
    B=[i%mod for i in A if i%mod!=0]
    if B==[] : print(mod);exit()
    if len(B)==1:
        q=B[0]
        if 0<=q<=k or mod-k<=q: print(mod);exit()
        else:continue
    B.sort()
    r=[B[0]]*len(B)
    for i in range(len(B)-1):
        r[i+1]= r[i]+B[i+1]
    now=float("INF")
    for i in range(1,len(B)): #切り方
        if r[i-1] ==  mod*(len(B)-i)-(r[-1]-r[i-1]) and r[i-1]<=k:
            print(mod);exit()
def main():
  a, v = map(int,input().split())
  b, w = map(int,input().split())
  t = int(input())
  ans = True

  a_can_plus = min(a + v * t, 10 ** 8)
  a_can_minus = max(a - v * t, -10 ** 8)
  b_can_plus = min(b + w * t, 10 ** 8)
  b_can_minus = max(b - w * t, -10 ** 8)
  # print(a_can_plus)
  # print(a_can_minus)
  # print(b_can_plus)
  # print(b_can_minus)

  if v - w < 0: 
    ans  = False
  elif (v - w) * t >= abs(a - b):
    ans = True
  elif a > b:
        if b_can_minus < a_can_minus:
      ans = False
    else:
      ans = True  
  elif a < b:
    if a_can_plus < b_can_plus:
      ans = False
    else:
      ans = True
      
  if ans:
    print("YES")
  else:
    print("NO")            


main()


### FIXED CODE ###

def main():
  a, v = map(int,input().split())
  b, w = map(int,input().split())
  t = int(input())
  ans = True

  if v - w < 0: 
    ans  = False
  elif (v - w) * t >= abs(a - b):
    ans = True
  else:
    ans = False
      
  if ans:
    print("YES")
  else:
    print("NO")            


main()
import sys
import queue
def main():
    input=sys.stdin.readline
    n,x,y=map(int,input().split())
    edge=[]
    for i in range(int(n)):
        tmp=[0 if i==j else 1 if abs(i-j)==1 else -1 for j in range(n)]
        edge.append(tmp)
    edge[x-1][y-1]=1
    edge[y-1][x-1]=1
    step=[0]*n#ある歩数の点の選び方をカウントする
    def bfs(start,graph,step):
        kyori={}#スタートからある点までの距離をある点をキーとして入れる
        que_check=[0]*n#queueに入ったかを記録する
        Tovis=queue.Queue()#探索待ちの点を入れるキュー
        Tovis.put(start)
        que_check[start]=1
        kyori[start]=0        
        while Tovis.empty()==False:            
            nex=Tovis.get()            
            for v in range(n):                
                tmp=graph[nex][v]
                if tmp!=-1:                    
                    if que_check[v]==1:
                        continue
                    Tovis.put(v)
                    que_check[v]=1
                    res=kyori[nex]+1
                    kyori[v]=res#点ｖまでの距離はその前に通った点までの距離+1
                    step[res]+=0.5#i->j j->iの二回数えてしまうので
    for i in range(n):
        bfs(i,edge,step)
    for i in range(1,len(step)):
        print(int(step[i]))
if __name__ == '__main__':
    main()       


### FIXED CODE ###

s=input()

x=1
if s[2]!=s[3]:
    x=0
    
if s[4]!=s[5]:
    x=0
    
        
if x==1:
    print("Yes")
else:
    print("No")
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    X, N = LI()
    if N == 0:
        print(X)
        return

    p = LI()

    p_max = max(p)
    p_min = min(p)

    if X < p_min or p_max < X:
        print(X)
        return
    else:
        d = [abs(i-X) for i in range(p_min, p_max+1) if i not in p]
        d_min = min(d)
        for i in range(p_min, p_max+1):
            if i not in p:
                if abs(i-X)==d_min:
                    print(i)
                    return

if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    X, N = LI()
    if N == 0:
        print(X)
        return

    p = LI()

    p_max = max(p)
    p_min = min(p)

    if X < p_min or p_max < X:
        print(X)
        return
    else:
        d = [abs(i-X) for i in range(0, 102) if i not in p]
        d_min = min(d)
        for i in range(0, 102):
            if i not in p:
                if abs(i-X)==d_min:
                    print(i)
                    return

if __name__ == '__main__':
    resolve()
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]

dp = [[1000 for _ in range(W+1)] for _ in range(H+1)]
dp[0][1] = 0
dp[1][0] = 0

for y in range(W):
    for x in range(H):
        dp[y+1][x+1] = min(
            dp[y][x+1] + (s[y][x] == '#' and (y == 0 or s[y-1][x] == '.')),
            dp[y+1][x] + (s[y][x] == '#' and (x == 0 or s[y][x-1] == '.'))
        )

print(dp[-1][-1])


### FIXED CODE ###

H, W = map(int,input().split())
board = []
for h in range(H):
    board.append(input())

dp=[[1000 for i in range(W+1)] for j in range(H+1)]
dp[0][1] = 0
dp[1][0] = 0

for h in range(H):
    for w in range(W):
        dp[h+1][w+1] = min(
            dp[h][w+1] + (board[h][w]=='#' and (h==0 or board[h-1][w]=='.')),
            dp[h+1][w] + (board[h][w]=='#' and (w==0 or board[h][w-1]=='.'))
        )

print (dp[-1][-1])
def counting_sort(MAX):
    C = [0 for _ in range(MAX+1)]

    for i in range(N):
        C[A[i]] += 1

    for i in range(1, MAX+1):
        C[i] = C[i] + C[i-1]

    for i in range(N-1, -1, -1):
        C[A[i]] -= 1
        B[C[A[i]]] = A[i]

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

MAX = 0
for n in A:
    if MAX < n:
        MAX = n

B = [0 for _ in range(N)]
counting_sort(MAX)
print(" ".join(B))


### FIXED CODE ###

def counting_sort(MAX):
    C = [0 for _ in range(MAX+1)]

    for i in range(N):
        C[A[i]] += 1

    for i in range(1, MAX+1):
        C[i] = C[i] + C[i-1]

    for i in range(N-1, -1, -1):
        C[A[i]] -= 1
        B[C[A[i]]] = A[i]

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

MAX = 10001

B = [0 for _ in range(N)]
counting_sort(MAX)
print(" ".join(map(str, B)))