CodeEff/ECCO huggingface dataset:
# Original solution
from collections import Counter

N = int(eval(input()))
input_list = []
input_counter = Counter()
ans = 10**10
index = 1
for i in input().split():
    item = int(i) - index
    input_list.append(item)
    input_counter[item] += 1
    index += 1


for i in list(input_counter.keys()):
    ans = min(ans, sum([abs(x-i)*input_counter[x] for x in list(input_counter.keys())]))

print(ans)

# Optimized solution
N = int(eval(input()))

input_list = []
index = 1
for i in input().split():
    item = int(i) - index
    input_list.append(item)
    index += 1

input_list.sort()
b = input_list[N//2]

print((sum([abs(x-b) for x in input_list])))
# Original solution
def main():
    N, *A = list(map(int, open(0).read().split()))
    for i in range(N):
        A[i] -= i + 1
    A.sort()
    b = A[N // 2]
    print((sum([abs(A[i] - b) for i in range(N)])))
    return


main()


# Optimized solution
def main():
    N, *A = list(map(int, open(0).read().split()))
    for i in range(N):
        A[i] -= i + 1
    A.sort()
    print((sum(A[N // 2 + N % 2:]) - sum(A[:N // 2])))
    return


main()
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
left = -10**9
right = 10**9
minnum = 0
for i in range(n):
  minnum += abs(a[i]-(left+(i+1)))

ans = 0
def cal(num):
  global minnum
  tmp = 0
  for i in range(n):
    tmp += abs(a[i]-(num+(i+1)))
  return tmp
 

while abs(right-left)>1:
  mid = (right+left)//2
  if cal(mid-1)<cal(mid+1):
    ans = mid
    right = mid
  else:
    left = mid
print((min(cal(left),cal(right))))

# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))
left = -10**9
right = 10**9
def cal(num):
  tmp = 0
  for i in range(n):
    tmp += abs(a[i]-(num+(i+1)))
  return tmp
 

while abs(right-left)>1:
  mid = (right+left)//2
  if cal(mid-1)<cal(mid+1):
    ans = mid
    right = mid
  else:
    left = mid
print((min(cal(left),cal(right))))
# Original solution
from functools import lru_cache
import sys
input = sys.stdin.readline
n = int(eval(input()))
a = tuple(map(int,input().split()))
left = -10**9
right = 10**9

@lru_cache(maxsize=100000)
def cal(num):
  tmp = 0
  for i in range(n):
    tmp += abs(a[i]-(num+(i+1)))
  return tmp

while abs(right-left)>1:
  mid = (right+left)//2
  if cal(mid-1)<cal(mid+1):
    right = mid
  else:
    left = mid
print((min(cal(left),cal(right))))

# Optimized solution
from functools import lru_cache
import sys
input = sys.stdin.readline
n = int(eval(input()))
a = list(map(int,input().split()))
left = -10**9
right = 10**9

@lru_cache(maxsize=100000)
def cal(num):
  tmp = 0
  for i in range(n):
    tmp += abs(a[i]-(num+(i+1)))
  return tmp
 

while abs(right-left)>1:
  mid = (right+left)//2
  if cal(mid-1)<cal(mid+1):
    right = mid
  else:
    left = mid
print((min(cal(left),cal(right))))
# Original solution
N=int(eval(input()))
l=list(map(int,input().split()))
max_n=max(l)
min_n=min(l)
res=float('inf')
for j in range(max_n-min_n+N+1):
  ans=0
  for i in range(N):
    ans+=abs(max_n+i-l[i]-j)
  if res > ans:
    res = ans
print(res)

# Optimized solution
N=int(eval(input()))
l=list(map(int,input().split()))
for i in range(N):
  l[i] -= i
l.sort()
center_num=l[N//2]
ans=0
for i in range(N):
  ans+=abs(l[i]-center_num)
print(ans)
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
aa = []
for i in range(n):
    aa.append(a[i]-(i+1))
b = (sorted(aa)[n//2])

ans = 0
for i in range(n):
    ans += abs(a[i]-(b+i+1))
print(ans)

# Optimized solution
N= int(eval(input()))
A = list(map(int,input().split()))

B = []
for i in range(N):
    B.append(A[i]-(i+1))
#print(B)
b= (sorted(B)[N//2])
#print(b)
ans = 0
for i in range(N):
    ans += abs(B[i]-b)
print(ans)
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
l = len(a)
b = [a[i]-(i+1) for i in range(n)]
b = sorted(b)
mid = b[l//2]
sum = 0
for i in range(n):
    sum+=abs(a[i]-(mid+(i+1)))
print(sum)


# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))
for i in range(n):
  a[i] -= i + 1
a = sorted(a)

def calc(mid):
  res = 0
  for i in a:
    res += abs(i-mid)
  return res

if n%2==1:
  res = calc(a[n//2])
else:
  res = float('inf')
  if (a[n//2-1]+a[n//2])%2==0:
    res = calc((a[n//2-1]+a[n//2])//2)
  else:
    mid = (a[n//2-1]+a[n//2]) // 2
    res = min(calc(mid), calc(mid+1))

print(res)
# Original solution
a = int(eval(input()))
ar = list(map(int,input().split(" ")))
cr = []
for j in range(-max(ar),max(ar)+1):
    count = 0
    for i in range(a):
        count += abs(ar[i] - (i+1 + j))
    cr.append(count)
print((min(cr)))

# Optimized solution
a = int(eval(input()))
ar = list(map(int,input().split(" ")))
ar = [r - (i+1) for i,r in enumerate(ar)]
br = sorted(ar)
b = br[a//2]
count = 0
for i in range(a):
    count += abs(ar[i] - b)
print(count)
# Original solution
N=int(eval(input()))
A=[int(i) for i in input().split()]
s=0
t=0
for i in range(N):
    s+=abs(A[i]-1-i)
    t+=abs(A[i]-i)
if s>t:
    d=0
    while True:
        d-=1
        r=0
        u=0
        for i in range(N):
            r+=abs(A[i]-d-1-i)
            u+=abs(A[i]-d-i)
        if r>u:
            continue
        else:
            print(r)
            break
elif s==t:
    print(s)
else:
    e=0
    while True:
        e+=1
        x=0
        y=0
        for i in range(N):
            x+=abs(A[i]-e-1-i)
            y+=abs(A[i]-e-i)
        if x<y:
            continue
        else:
            print(y)
            break

# Optimized solution
N=int(eval(input()))
A=[int(i) for i in input().split()]
u=[]
for i in range(N):
    u.append(A[i]-i)
a=sorted(u)
if len(a)%2==0:
    p=a[len(a)//2]
else:
    p=a[len(a)//2]
ans=0
for j in range(N):
    ans+=abs(a[j]-p)
print(ans)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

res = 0
for i in range(N):
    res += A[i] - (i+1)
b = res // N

ans = 99999999
for bj in range(b-100, b+100):
    res = 0
    for i in range(N):
        res += abs(A[i] - (b+(i+1)))
    ans = min(ans, res)
print(ans)

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))

A_sorted = sorted([A[i] - (i+1) for i in range(N)])

if len(A) != 1:
    b = A_sorted[int((len(A)-1)/2)]
    b2 = A_sorted[int((len(A)-1)/2 + 1)]
    sad_1 = sum([abs(A_sorted[i] - b) for i in range(N)])
    sad_2 = sum([abs(A_sorted[i] - b2) for i in range(N)])
    print((min(sad_1, sad_2)))
else:
    print('0')
# Original solution
from bisect import bisect

n=int(eval(input()))
a=list(map(int,input().split()))

a2=[]

for i in range(n):
    temp = a[i]-(i+1)
    index = bisect(a2,temp)
    a2.insert(index,temp)

ans = sum( abs(x - a2[n//2]) for x in a2)
print(ans)

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))

a2 = [ x-i for i,x in enumerate(a)]
a2.sort()

ans = sum( abs(x - a2[n//2]) for x in a2)
print(ans)
# Original solution
n = int(eval(input()))
a = [int(i) for i in input().split()]

b = []
for i in range(len(a)):
    b.append(a[i] - (i+1))

while True:
    p_num = []
    n_num = []
    z_num = []
    for i in range(len(b)):
        if b[i] > 0:
            p_num.append(b[i])
        elif b[i] < 0:
            n_num.append(b[i])
        else:
            z_num.append(b[i])

    if len(p_num) > len(n_num) + len(z_num):
        for i in range(len(b)):
            b[i] = b[i] - 1
    elif len(n_num) > len(p_num) + len(z_num):
        for i in range(len(b)):
            b[i] = b[i] + 1
    else:
        break

ans = 0
for i in range(len(b)):
    ans += abs(b[i])

print(ans)


# Optimized solution
n = int(eval(input()))
a = [int(i) for i in input().split()]

b = []
for i in range(len(a)):
    b.append(a[i] - (i+1))

p_num = []
n_num = []
z_num = []

for i in range(len(b)):
    if b[i] > 0:
        p_num.append(b[i])
    elif b[i] < 0:
        n_num.append(b[i])
    else:
        z_num.append(b[i])

p_num.sort()
n_num.sort()
n_num.reverse()

if len(p_num) > len(n_num) + len(z_num):
    count_n = len(n_num) + len(z_num)
    count_p = len(p_num)
    index = -1
    while  count_p > count_n:
        count_p -= 1
        count_n += 1
        index += 1
    for i in range(len(b)):
        b[i] = b[i] - p_num[index]

elif len(n_num) > len(p_num) + len(z_num):
    count_n = len(n_num)
    count_p = len(p_num) + len(z_num)
    index = -1
    while  count_n > count_p:
        count_n -= 1
        count_p += 1
        index += 1
    for i in range(len(b)):
        b[i] = b[i] - n_num[index]

ans = 0
for i in range(len(b)):
    ans += abs(b[i])

print(ans)
# Original solution
def 解():
    iN = int(eval(input()))
    aA = list(map(int,input().split()))
    aA = sorted(map(lambda x,y:x-y,aA,list(range(1,iN+1))))
    iL = len(aA)
    if iL % 2 :
        iMed = aA[(iL-1)//2]
    else:
        iMed = aA[iL//2]
    iMean = sum(aA) // 2
    iBlim= min(iMed,iMean)
    iUlim= min(iMed,iMean+1)

    print((min(sum(abs(a-i) for a in aA) for i in [iMed,iMean,iMean+1])))

解()


# Optimized solution
def 解():
    iN = int(eval(input()))
    #aA = map(int,input().split())
    aA = sorted(map(lambda x,y:x-y,list(map(int,input().split())),list(range(1,iN+1))))
    iL = len(aA)
    if iL % 2 :
        iMed = aA[(iL-1)//2]
    else:
        iMed = aA[iL//2]
    print((sum(abs(a-iMed) for a in aA)))

解()
# Original solution
from statistics import mean
import math

N = int(eval(input()))
A = list(map(int, input().split()))
A = [A[idx]-(idx+1) for idx in range(N)]

b = round(mean(A))

ans1 = 0
ans2 = 0
for i in range(N):
    ans1 += abs(math.floor(mean(A))-A[i])
    ans2 += abs(math.ceil(mean(A)) - A[i])
    
print((min(ans1,ans2)))

# Optimized solution
from statistics import median
import math

N = int(eval(input()))
A = list(map(int, input().split()))
A = [A[idx]-(idx+1) for idx in range(N)]

ans1 = 0
ans2 = 0
median_A = median(A)
median_floor_A = math.floor(median_A)
median_ceil_A = math.ceil(median(A))

for i in range(N):
    ans1 += abs(median_floor_A - A[i])
    ans2 += abs(median_ceil_A - A[i])
    
print((min(ans1,ans2)))
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))
tmp = sorted([A[i-1]-i for i in range(1,N+1)])
mid = tmp[N//2]
print((sum([abs(t-mid) for t in tmp])))

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
tmp = sorted([A[i-1]-i for i in range(1,N+1)])
B = tmp[N//2]
print((sum([abs(t-B) for t in tmp])))
# Original solution
# https://atcoder.jp/contests/abc102/tasks/arc100_a
# C - Linear Approximation

N = int(input().split()[0])
a_list = list(map(int, input().split()))
min_b = float('inf')
max_a = max(a_list)

work_list = [a - i - 1 for i, a in enumerate(a_list)]
work_list = list(set(work_list))

for b in work_list:  # 10 ** 5
    total_b = 0
    for i, a in enumerate(a_list):  # 10 ** 5
        total_b += abs(a - (b + i + 1))
    min_b = min(min_b, total_b)

print(min_b)


# Optimized solution
# https://atcoder.jp/contests/abc102/tasks/arc100_a
# C - Linear Approximation

N = int(input().split()[0])
a_list = list(map(int, input().split()))
min_b = float('inf')
max_a = max(a_list)

work_list = [a - (i + 1) for i, a in enumerate(a_list)]
w = sorted(work_list)[int(N / 2)]
ans = sum([abs(x - w) for x in work_list])
print(ans)
# Original solution
n=int(eval(input()))
A=list(map(int,input().split()))
for i in range(n):
    A[i]=A[i]-i-1

B=sorted(A)
b=B[n//2]

r=0
for i in range(n):
   r+=abs(A[i]-b)
print(r)

# Optimized solution
n=int(eval(input()))
A=list(map(int,input().split()))
B=sorted([A[i]-(i+1) for i in range(n)])
if n%2==1:
    b=B[n//2]
else:
    b=(B[n//2-1]+B[n//2])//2
r=0
for i in range(n):
    r+=abs(B[i]-b)
print(r)
# Original solution
import statistics
N = int(eval(input()))
A = [int(a)-i-1 for i,a in enumerate(input().split(),1)]
b = statistics.median_low(A)
c = statistics.median_high(A)
d = sum([abs(x-b) for x in A])
e = sum([abs(x-c) for x in A])
print((min(d,e)))

# Optimized solution
N=int(eval(input()))
A=sorted(a-i-1 for i,a in enumerate(map(int,input().split())))
print((sum(abs(a-A[N//2]) for a in A)))
# Original solution
n = int(eval(input()))
s = list(map(int, input().rstrip().split(" ")))

min_v = 0
for i in range(0, n):
    v = 0
    for j in range(0, n):
        v = v + abs(s[j] - (s[i]-i + j))
    if i == 0 or v < min_v:
        min_v =v
print(min_v)


# Optimized solution
n = int(eval(input()))
s = list(map(int, input().rstrip().split(" ")))

for i in range(0, n):
    s[i] = s[i] - (i+1)
s.sort()

b = s[n//2]

sm = 0
for i in range(0, n):
    sm = sm + abs(s[i] - b)

print(sm)
# Original solution
import math
n = int(eval(input()))
a_tmp = input().split()
a = []
for i in range(n):
    a.append(int(a_tmp[i]))
a1 = []
for i in range(n):
    a1.append(a[i]-1-i)
b_max = max(a1)
b_min = min(a1)
sadness = []
for b in range(b_min, b_max+1):
    abs = [math.fabs(a1[i]-b) for i in range(n)]
    sadness.append(int(sum(abs)))
print((min(sadness)))


# Optimized solution
import math
n = int(eval(input()))
a_tmp = input().split()
a_tmp1 = []
for i in range(n):
    a_tmp1.append(int(a_tmp[i])-i-1)
a = sorted(a_tmp1)
if n % 2 == 0:
    x = a[n//2]
else:
    x = a[n//2]
ans = 0
for _ in a:
    ans += math.fabs(_ - x)
print((int(ans)))
# Original solution
n = int(eval(input()))
A_list = list(map(int, input().split()))
for i in range(n):
    A_list[i] -= i
A_list.sort()
A_cum = [0] * n
for i in range(n):
    if i == 0:
        A_cum[0] = A_list[0]
    else:
        A_cum[i] = A_cum[i-1] + A_list[i]
def findinfindex(sortedlist, key, l, r):
    if r - l <= 0:
        return l
    m = (l+r+1)//2
    if sortedlist[m] > key:
        return findinfindex(sortedlist, key, l, m-1)
    else:
        return findinfindex(sortedlist, key, m, r)
sadmin = -1
for b in range(A_list[0],A_list[n-1]+1):
    lastminus = findinfindex(A_list, b, 0, n-1)
    sadness = (2*lastminus - n + 2)*b - 2*A_cum[lastminus] + A_cum[n-1]
    if sadmin == -1:
        sadmin = sadness
    elif sadness < sadmin:
        sadmin = sadness
    else:
        break
print(sadmin)


# Optimized solution
n = int(eval(input()))
A_list = list(map(int, input().split()))
for i in range(n):
    A_list[i] -= i
A_list.sort()

def sadness(a, mid):
    sad = 0
    for i in range(mid):
        sad += a[mid] - a[i]
    for i in range(mid+1,len(a)):
        sad += a[i] - a[mid]
    return sad

if n % 2 != 0:
    print((sadness(A_list, n//2)))
else:
    print((min(sadness(A_list, n//2), sadness(A_list, n//2+1))))
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))
a = list(range(1,N+1))
bbef = -N//2
baft = (-N//2)+1
elementbef = [abs(i-j-bbef) for (i,j) in zip(A,a)]
sumbef = sum(elementbef)
elementaft = [abs(i-j-baft) for (i,j) in zip(A,a)]
sumaft = sum(elementaft)
while(sumaft-sumbef < 0):
    bbef = bbef+1
    baft = baft+1
    elementbef = [abs(i-j-bbef) for (i,j) in zip(A,a)]
    sumbef = sum(elementbef)
    elementaft = [abs(i-j-baft) for (i,j) in zip(A,a)]
    sumaft = sum(elementaft)
print(sumbef)

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
a = list(range(1,N+1))
elements = sorted([i-j for (i,j) in zip(A,a)])
if(N%2 == 1):
    b = elements[N//2]
else:
    b = elements[(N//2)-1]
answer = sum([abs(i-j-b) for (i,j) in zip(A,a)])
print(answer)
# Original solution
n = int(eval(input()))
A = [int(i) for i in input().split()]
M = []

for i in range(n):
    M.append(A[i] - (i + 1))
    
M.sort()
b = M[len(M) // 2]

ans = 0
for i in range(n):
    ans += abs(A[i] - (b + i + 1))
    
print(ans)

# Optimized solution
n = int(eval(input()))
A = [int(i) for i in input().split()]
B = []

for i in range(n):
    B.append(A[i] - i)

B.sort()
mid = B[len(B)//2]

ans = 0
for i in range(n):
    ans += abs(A[i] - (mid + i))
    
print(ans)
# Original solution
N=int(eval(input()))
A=list(map(int,input().split()))
A=[a-i for i,a in enumerate(A,1)]
A.sort()
A_posi=[0 for i in range(N)]
A_posi[0]=A[0]
for i in range(1,N):
    A_posi[i]=A_posi[i-1]+A[i]
value=[0 for i in range(N)]
value[0]=A_posi[N-1]-N*A[0]
for i in range(1,N):
    value[i]=A_posi[N-1]-A_posi[i]-(N-i-1)*A[i]-A_posi[i-1]+(i)*A[i]
print((min(value)))


# Optimized solution
N=int(eval(input()))
A=list(map(int,input().split()))
A=[a-i for i,a in enumerate(A,1)]
A.sort()
b=A[len(A)//2]
A=[abs(a-b) for a in A]
print((sum(A)))
# Original solution
N=int(eval(input()))
A=list(map(int,input().split()))
def quick_sort(a):
    if len(a)<= 1:
        return a
    else:
        b=[]
        c=[]
        for i in range(1, len(a)):
            if a[i]<a[0]:
                b.append(a[i])
            else:
                c.append(a[i])
        return quick_sort(b)+[a[0]]+quick_sort(c)
def abs(x):
    if x>=0:
        return x
    else:
        return x*(-1)
B=[]
for i in range(N):
  B.append(A[i]-i-1)
C=quick_sort(B)
if N%2==0:
  b=(C[N//2]+C[N//2-1])//2
else:
  b=C[N//2-1]
sad=0
for j in range(N):
  sad=sad+abs(C[j]-b)
print(sad)

# Optimized solution
N=int(eval(input()))
A=list(map(int,input().split()))
B=[]
for i in range(N):
  B.append(A[i]-i-1)
B.sort()
if N%2==0:
  b=(B[N//2]+B[N//2-1])//2
else:
  b=B[N//2]
sad=0
for j in range(N):
  sad=sad+abs(B[j]-b)
print(sad)
# Original solution
# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

# 7
# 1 1 1 1 2 3 4
#import sys

N = int(eval(input()))
a = list(map(int, input().strip().split(" ")))

for i in range(N):
    a[i] = a[i] - (i+1)

a.sort()
max = a[-1]
min = a[0]

for b in range(min, max + 1):
    sadness_left = 0
    i = 0
    while a[i] < b:
        sadness_left += b - a[i]
        i += 1
    sadness = sum(a) - b * N + sadness_left * 2
    if b == min:
        min_sadness = sadness
    elif min_sadness > sadness:
        min_sadness = sadness

print(min_sadness)


# Optimized solution
# C - Linear Approximation
# https://beta.atcoder.jp/contests/abc102/tasks/arc100_a

# C_Linear_Approximation.py

# 7
# 1 1 1 1 2 3 4
#import sys

N = int(eval(input()))
a = list(map(int, input().strip().split(" ")))

for i in range(N):
    a[i] = a[i] - (i+1)

a.sort()
if N % 2 != 0:
    mid = (N-1)//2
else:
    mid = N // 2 -1
b = a[mid]

sadness_left = b * mid - sum(a[:mid])
sadness = sum(a) - b * N + sadness_left * 2

print(sadness)
# Original solution
n,m,d = (int(i) for i in input().split())
step = n-d
if d != 0:
  step =step*2
print(('{:.10f}'.format(step*n**(m-2)*(m-1)/n**m)))


# Optimized solution
n,m,d = (int(i) for i in input().split())
step = n-d
if d != 0:
  step =step*2
print(('{:.10f}'.format(step*(m-1)/n**2)))
# Original solution
import sys
input=sys.stdin.readline

S = input().strip()
n = S.count("N")
w = S.count("W")
e = S.count("E")
s = S.count("S")

if (n == 0 and s == 0) or (n > 0 and s > 0):
    if (w == 0 and e == 0) or (w > 0 and e > 0):
        print("Yes")
        exit()
print("No")


# Optimized solution
import sys
input=sys.stdin.readline

S = input().strip()
n = S.count("N") > 0
w = S.count("W") > 0
e = S.count("E") > 0
s = S.count("S") > 0

if (n and not s) or (not n and s) or (w and not e) or (not w and e):
    print("No")
else:
    print("Yes")
# Original solution
# AGC003A - Wanna go back home
from collections import Counter


def main():
    D = Counter(input().rstrip())
    flg = True
    if (
        (D["N"] != 0 and D["S"] == 0)
        or (D["N"] == 0 and D["S"] != 0)
        or (D["E"] != 0 and D["W"] == 0)
        or (D["E"] == 0 and D["W"] != 0)
    ):
        flg = False
    print(("Yes" if flg else "No"))


if __name__ == "__main__":
    main()

# Optimized solution
# AGC003A - Wanna go back home
def main():
    S = input().rstrip()
    flg = (("N" in S) ^ ("S" in S) ^ 1) & (("E" in S) ^ ("W" in S) ^ 1)
    print(("Yes" if flg else "No"))


if __name__ == "__main__":
    main()
# Original solution
# code-festival-2017-qualaC - Palindromic Matrix
from collections import Counter


def main():
    H, W, *A = open(0).read().split()
    H, W, C = int(H), int(W), list(Counter("".join(A)).values())
    single = H & W & 1
    double = (H >> 1 if W & 1 else 0) + (W >> 1 if H & 1 else 0)
    C_mod4, C_div4 = list(zip(*[(i % 4, i // 4) for i in C]))
    flg = C_mod4.count(1) + C_mod4.count(3) <= single and C_mod4.count(2) <= double
    print(("Yes" if flg else "No"))


if __name__ == "__main__":
    main()

# Optimized solution
# code-festival-2017-qualaC - Palindromic Matrix
from collections import Counter


def main():
    H, W, *A = open(0).read().split()
    H, W, C = int(H), int(W), list(Counter("".join(A)).values())
    single = H & W & 1
    double = (H >> 1 if W & 1 else 0) + (W >> 1 if H & 1 else 0)
    C_mod4 = [i % 4 for i in C]
    flg = C_mod4.count(1) + C_mod4.count(3) <= single and C_mod4.count(2) <= double
    print(("Yes" if flg else "No"))


if __name__ == "__main__":
    main()
# Original solution
# code-festival-2017-qualaC - Palindromic Matrix
from collections import defaultdict


def main():
    H, W, *A = open(0).read().split()
    H, W, C = int(H), int(W), defaultdict(int)
    for i in "".join(A):
        C[i] += 1
    single = H & W & 1
    double = (H >> 1 if W & 1 else 0) + (W >> 1 if H & 1 else 0)
    C_mod4 = [i % 4 for i in list(C.values())]
    flg = C_mod4.count(1) + C_mod4.count(3) <= single and C_mod4.count(2) <= double
    print(("Yes" if flg else "No"))


if __name__ == "__main__":
    main()

# Optimized solution
# code-festival-2017-qualaC - Palindromic Matrix
def main():
    H, W, *A = open(0).read().split()
    H, W, C = int(H), int(W), {}
    for i in "".join(A):
        if i not in C:
            C[i] = 0
        C[i] += 1
    single = H & W & 1
    double = (H >> 1 if W & 1 else 0) + (W >> 1 if H & 1 else 0)
    C_mod4 = [i % 4 for i in list(C.values())]
    flg = C_mod4.count(1) + C_mod4.count(3) <= single and C_mod4.count(2) <= double
    print(("Yes" if flg else "No"))


if __name__ == "__main__":
    main()
# Original solution
H,W=list(map(int,input().split()))
lines=[]
for i in range(H):
    lines.append(input().strip())

chars=dict()
for line in lines:
    for c in line:
        if c not in chars:
            chars[c]=0
        chars[c]+=1

def judge(H,W,chars):
    #両方奇数
    if H%2+W%2==2:
        ones=1
        twos=H//2 + W//2
    #両方偶数
    elif H%2+W%2==0:
        ones=0
        twos=0
    elif H%2==1:
        ones=0
        twos=W//2
    else:
        ones=0
        twos=H//2
    for c in chars:
        if ones<0 or twos<0:
            return False
        chars[c]%=4
        if chars[c]==0:
            continue
        if chars[c]==2:
            twos-=1
        elif chars[c]==3:
            twos-=1
            ones-=1
        else:
            ones-=1
    if ones<0 or twos<0:
        return False
    return True

if judge(H,W,chars):
    print("Yes")
else:
    print("No")

# Optimized solution
H,W=list(map(int,input().split()))
lines=[]
for i in range(H):
    lines.append(input().strip())

chars=dict()
for line in lines:
    for c in line:
        if c not in chars:
            chars[c]=0
        chars[c]+=1

def judge(H,W,chars):
    #両方奇数
    if H%2+W%2==2:
        ones=1
        twos=H//2 + W//2
    #両方偶数
    elif H%2+W%2==0:
        ones=0
        twos=0
    elif H%2==1:
        ones=0
        twos=W//2
    else:
        ones=0
        twos=H//2
    for c in chars:
        chars[c]%=4
        if chars[c]==0:
            continue
        if chars[c]==2:
            twos-=1
        elif chars[c]==3:
            twos-=1
            ones-=1
        else:
            ones-=1
    if ones<0 or twos<0:
        return False
    return True

if judge(H,W,chars):
    print("Yes")
else:
    print("No")