CodeEff/ECCO huggingface dataset:
# Original solution
def merge_jibun(A, left, mid, right):
    global count
    # inf = 10 ** 9
    L = A[left:mid] + [10 ** 9]
    R = A[mid:right] + [10 ** 9]
    # L.append(1000000)
    # R.append(1000000)

    i = 0
    j = 0
    
    
    for k in range(left, right):
        count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def merge_hoka(A, left, mid, right):
    global count
    inf = 10 ** 9
    L = A[left:mid] + [inf]
    R = A[mid:right] + [inf]
 
    i = 0
    j = 0
    for k in range(left, right):
        count += 1
        # print(L)
        # print(R)
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge_jibun(A, left, mid, right)
        # merge_hoka(A, left, mid, right)

n = int(eval(input()))
A = list(map(int, input().split()))
count = 0
mergeSort(A, 0, n)

print((' '.join(list(map(str, A)))))
print(count)


# Optimized solution
def merge_jibun(A, left, mid, right):
    global count
    inf = 10 ** 9
    L = A[left:mid] + [inf]
    R = A[mid:right] + [inf]

    i = 0
    j = 0
    for k in range(left, right):
        count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

# def merge_hoka(A, left, mid, right):
#     global count
#     inf = 10 ** 9
#     L = A[left:mid] + [inf]
#     R = A[mid:right] + [inf]
 
#     i = 0
#     j = 0
#     for k in range(left, right):
#         count += 1
#         # print(L)
#         # print(R)
#         if L[i] <= R[j]:
#             A[k] = L[i]
#             i += 1
#         else:
#             A[k] = R[j]
#             j += 1

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge_jibun(A, left, mid, right)
        # merge_hoka(A, left, mid, right)

n = int(eval(input()))
A = list(map(int, input().split()))
count = 0
mergeSort(A, 0, n)

print((' '.join(list(map(str, A)))))
print(count)
# Original solution

count = 0

def merge_sort(arr):
	merge_sort_(arr, 0, len(arr) - 1)

def merge_sort_(arr, floor, ceiling):
	if floor < ceiling:
		mid = int(floor + (ceiling - floor) / 2)
		merge_sort_(arr, floor, mid)
		merge_sort_(arr, mid + 1, ceiling)
		merge(arr, floor, mid, ceiling)

def merge(arr, floor, mid, ceiling):
	global count
	temp_arr = [0] * len(arr)
	for i in range(floor, ceiling + 1):
		temp_arr[i] = arr[i]
	
	i = floor
	j = mid + 1
	k = floor
	while k <= ceiling:
		count += 1
		if j > ceiling or (i <= mid and temp_arr[i] <= temp_arr[j]):
			arr[k] = temp_arr[i]
			i += 1
		else:
			arr[k] = temp_arr[j]
			j += 1
		k += 1
		
n = int(input())
arr = list(map(int, input().split()))
merge_sort(arr)
for i in range(n):
	print(arr[i], end="")
	if i != n - 1:
		print(" ", end="")
print()
print(count)




# Optimized solution
import sys
count = 0

def merge_sort(arr):
	merge_sort_(arr, 0, len(arr))

def merge_sort_(arr, left, right):
	if left + 1 < right:
		mid = int(left + (right - left) / 2)
		merge_sort_(arr, left, mid)
		merge_sort_(arr, mid, right)
		merge(arr, left, mid, right)

def merge(arr, left, mid, right):
	global count
	
	n1 = mid - left
	n2 = right - mid
	
#	L = [0] * (n1 + 1)
#	R = [0] * (n2 + 1)
#	for i in range(n1):
#		L[i] = arr[left + i]
#	for i in range(n2):3
#		R[i] = arr[mid + i]
#	L[n1] = R[n2] = sys.maxsize
	
	L = arr[left:left + n1]
	R = arr[mid:mid + n2]
	L.append(sys.maxsize)
	R.append(sys.maxsize)

	i = j = 0
	for k in range(left, right):
		count += 1
		if L[i] <= R[j]:
			arr[k] = L[i]
			i += 1
		else:
			arr[k] = R[j]
			j += 1

n = int(eval(input()))
arr = list(map(int, input().split()))
merge_sort(arr)
print((" ".join(map(str, arr))))
#for i in range(n):
#	print(arr[i], end="")
#	if i != n - 1:
#		print(" ", end="")
#print()
print(count)
# Original solution
# -*- coding: utf-8 -*-

def merge(A, left, mid, right):
    global cnt
    n1 = mid - left
    n2 = right - mid
    L = [None]*(n1+1)
    R = [None]*(n2+1)
    L[:n1] = A[left:left+n1]
    R[:n2] = A[mid:mid+n2]

    L[n1] = float('inf')
    R[n2] = float('inf')
    i = 0
    j = 0
    for k in range(left, right):
        cnt += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)
    
if __name__ == '__main__':

    n = int(eval(input()))
    S = [int(s) for s in input().split(" ")]
    cnt = 0

    mergeSort(S, 0, n)

    print((" ".join(map(str, S))))
    print(cnt)


# Optimized solution
# -*- coding: utf-8 -*-

def merge(A, left, mid, right):
    global cnt
    n1 = mid - left
    n2 = right - mid
    L = A[left:left+n1]
    R = A[mid:mid+n2]
    L.append(float('inf'))
    R.append(float('inf'))
    
    i = 0
    j = 0
    for k in range(left, right):
        cnt += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)
    
if __name__ == '__main__':

    n = int(eval(input()))
    S = [int(s) for s in input().split(" ")]
    cnt = 0

    mergeSort(S, 0, n)

    print((" ".join(map(str, S))))
    print(cnt)
# Original solution
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_B&lang=jp
def merge(target_list, left_index, right_index):
    global count
    mid_index = (left_index + right_index) // 2
    l = target_list[left_index:mid_index] + [pow(10,9) + 1]
    r = target_list[mid_index:right_index] + [pow(10,9) + 1]
    l_target = 0
    r_target = 0
    #print(left_index, right_index, mid_index, l,r)
    for k in range(left_index, right_index):
        count += 1
        if l[l_target] < r[r_target]:
            target_list[k] = l[l_target]
            l_target += 1
        else:
            target_list[k] = r[r_target]
            r_target += 1
    #print(target_list)
def merge_sort(target_list, left_index, right_index):
    if left_index + 1 < right_index:
        mid_index = (left_index + right_index) // 2

        merge_sort(target_list, left_index, mid_index)
        merge_sort(target_list, mid_index, right_index)
        merge(target_list, left_index, right_index)
    
if __name__ == "__main__":
    l = eval(input())
    target_list = [int(a) for a in input().split()]
    global count
    count = 0
    merge_sort(target_list, 0, len(target_list))
    print((" ".join([str(n) for n in target_list])))
    print(count)

# Optimized solution
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_B&lang=jp
def merge(target_list, left_index, mid_index,right_index):
    global count
    l = target_list[left_index:mid_index] + [pow(10,9) + 1]
    r = target_list[mid_index:right_index] + [pow(10,9) + 1]
    l_target = 0
    r_target = 0
    #print(left_index, right_index, mid_index, l,r)
    for k in range(left_index, right_index):
        count += 1
        if l[l_target] < r[r_target]:
            target_list[k] = l[l_target]
            l_target += 1
        else:
            target_list[k] = r[r_target]
            r_target += 1
    #print(target_list)
            
def merge_sort(target_list, left_index, right_index):
    if left_index + 1 < right_index:
        mid_index = (left_index + right_index) // 2

        merge_sort(target_list, left_index, mid_index)
        merge_sort(target_list, mid_index, right_index)
        merge(target_list, left_index, mid_index,right_index)
    
if __name__ == "__main__":
    l = eval(input())
    target_list = [int(a) for a in input().split()]
    global count
    count = 0
    merge_sort(target_list, 0, len(target_list))
    print((" ".join([str(n) for n in target_list])))
    print(count)
# Original solution
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_B&lang=jp
sentinel = pow(10,9) + 1
def merge(target_list, left_index, mid_index,right_index):
    global count
    l = target_list[left_index:mid_index] + [sentinel]
    r = target_list[mid_index:right_index] + [sentinel]
    l_target = 0
    r_target = 0
    #print(left_index, right_index, mid_index, l,r)
    for k in range(left_index, right_index):
        count += 1
        if l[l_target] < r[r_target]:
            target_list[k] = l[l_target]
            l_target += 1
        else:
            target_list[k] = r[r_target]
            r_target += 1

    #print(target_list)
            
def merge_sort(target_list, left_index, right_index):
    count = 0
    if left_index + 1 < right_index:
        mid_index = (left_index + right_index) // 2

        merge_sort(target_list, left_index, mid_index)
        merge_sort(target_list, mid_index, right_index)
        merge(target_list, left_index, mid_index,right_index)
        
if __name__ == "__main__":
    l = eval(input())
    target_list = [int(a) for a in input().split()]
    global cnt
    count = 0
    merge_sort(target_list, 0, len(target_list))
    print((" ".join([str(n) for n in target_list])))
    print(count)

# Optimized solution
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_B&lang=jp
sentinel = pow(10,9) + 1
def merge(target_list, left_index, mid_index,right_index):
    
    l = target_list[left_index:mid_index] + [sentinel]
    r = target_list[mid_index:right_index] + [sentinel]
    l_target = 0
    r_target = 0
    count = 0
    #print(left_index, right_index, mid_index, l,r)
    for k in range(left_index, right_index):
        count += 1
        if l[l_target] < r[r_target]:
            target_list[k] = l[l_target]
            l_target += 1
        else:
            target_list[k] = r[r_target]
            r_target += 1

    return count
    #print(target_list)
            
def merge_sort(target_list, left_index, right_index):
    count = 0
    if left_index + 1 < right_index:
        mid_index = (left_index + right_index) // 2

        count += merge_sort(target_list, left_index, mid_index)
        count += merge_sort(target_list, mid_index, right_index)
        count += merge(target_list, left_index, mid_index,right_index)
        
    return count
if __name__ == "__main__":
    l = eval(input())
    target_list = [int(a) for a in input().split()]
    count = merge_sort(target_list, 0, len(target_list))
    print((" ".join([str(n) for n in target_list])))
    print(count)
# Original solution
cnt = 0
def merge(A, left, mid, right):
  global cnt
  #print("marge ",A,left,mid,right)
  n1 = mid - left
  n2 = right - mid
  #L = [0] * (n1+1)
  #R = [0] * (n2+1)
  L = [0 for i in range(n1+1)]
  R = [0 for i in range(n2+1)]
  
  for i in range(int(n1)):
    L[i] = A[left + i]
  for i in range(int(n2)):
    R[i] = A[mid + i]
  L[n1] = 999999999
  R[n2] = 999999999
  i = 0
  j = 0
  for k in range(left,right):
    cnt+=1
    if L[i] <= R[j]:
      A[k] = L[i]
      i = i + 1
    else:
      A[k] = R[j]
      j = j + 1

def mergeSort(A, left, right):
  #print("margeSort ",A,left,right)
  if left+1 < right:
    mid = int((left + right)/2)
    mergeSort(A, left, mid)
    mergeSort(A, mid, right)
    merge(A, left, mid, right)

n = int(eval(input()))
S = list(map(int,input().split()))
mergeSort(S, 0, n)
S = list(map(str, S))
print((' '.join(S)))
print(cnt)


# Optimized solution
cnt = 0
def merge(A, left, mid, right):
  global cnt
  #print("marge ",A,left,mid,right)
  n1 = mid - left
  n2 = right - mid
  #L = [0] * (n1+1)
  #R = [0] * (n2+1)
  L = [0] * (n1+1)
  R = [0] * (n2+1)
  
  for i in range(int(n1)):
    L[i] = A[left + i]
  for i in range(int(n2)):
    R[i] = A[mid + i]
  L[n1] = 999999999
  R[n2] = 999999999
  i = 0
  j = 0
  for k in range(left,right):
    cnt+=1
    if L[i] <= R[j]:
      A[k] = L[i]
      i = i + 1
    else:
      A[k] = R[j]
      j = j + 1

def mergeSort(A, left, right):
  #print("margeSort ",A,left,right)
  if left+1 < right:
    mid = int((left + right)/2)
    mergeSort(A, left, mid)
    mergeSort(A, mid, right)
    merge(A, left, mid, right)

n = int(eval(input()))
S = list(map(int,input().split()))
mergeSort(S, 0, n)
S = list(map(str, S))
print((' '.join(S)))
print(cnt)
# Original solution
cnt = 0
def merge(A, left, mid, right):
  global cnt
  #print("marge ",A,left,mid,right)
  n1 = mid - left
  n2 = right - mid
  #L = [0] * (n1+1)
  #R = [0] * (n2+1)
  L = [0] * (n1+1)
  R = [0] * (n2+1)
  
  for i in range(int(n1)):
    L[i] = A[left + i]
  for i in range(int(n2)):
    R[i] = A[mid + i]
  L[n1] = 999999999
  R[n2] = 999999999
  i = 0
  j = 0
  for k in range(left,right):
    cnt+=1
    if L[i] <= R[j]:
      A[k] = L[i]
      i = i + 1
    else:
      A[k] = R[j]
      j = j + 1

def mergeSort(A, left, right):
  #print("margeSort ",A,left,right)
  if left+1 < right:
    mid = int((left + right)/2)
    mergeSort(A, left, mid)
    mergeSort(A, mid, right)
    merge(A, left, mid, right)

n = int(eval(input()))
S = list(map(int,input().split()))
mergeSort(S, 0, n)
S = list(map(str, S))
print((' '.join(S)))
print(cnt)


# Optimized solution
cnt = 0
def merge(A, left, mid, right):
  global cnt
  #print("marge ",A,left,mid,right)
  n1 = mid - left
  n2 = right - mid
  #L = [0] * (n1+1)
  #R = [0] * (n2+1)
  L = [0] * (n1+1)
  R = [0] * (n2+1)
  
  for i in range(n1):
    L[i] = A[left + i]
  for i in range(n2):
    R[i] = A[mid + i]
  L[n1] = 999999999
  R[n2] = 999999999
  i = 0
  j = 0
  for k in range(left,right):
    cnt+=1
    if L[i] <= R[j]:
      A[k] = L[i]
      i = i + 1
    else:
      A[k] = R[j]
      j = j + 1

def mergeSort(A, left, right):
  #print("margeSort ",A,left,right)
  if left+1 < right:
    mid = int((left + right)/2)
    mergeSort(A, left, mid)
    mergeSort(A, mid, right)
    merge(A, left, mid, right)

n = int(eval(input()))
S = list(map(int,input().split()))
mergeSort(S, 0, n)
S = list(map(str, S))
print((' '.join(S)))
print(cnt)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
count=0


def merge(A, left, mid, right):
    global count
    n1 = mid - left
    n2 = right - mid
    L = []
    R = []
    for i in range(n1):
        L.append(A[left + i])
    for i in range(n2):
        R.append(A[mid + i])

    L.append(float("inf"))
    R.append(float("inf"))
    i, j = 0, 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    count += right - left


def mergeSort(A, left, right):
    if left+1 < right:
        mid = (left + right)//2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

mergeSort(A,0,N)


print((" ".join(map(str,A))))
print(count)

# Optimized solution
def merge(a, left, mid, right):
    global count
    n1 = mid - left
    n2 = right - mid
    L = a[left:left + n1] + [SENTINEL]
    R = a[mid:mid + n2] + [SENTINEL]
    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            a[k] = L[i]
            i += 1
        else:
            a[k] = R[j]
            j += 1
    count += right - left
 
def merge_sort(a, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(a, left, mid)
        merge_sort(a, mid, right)
        merge(a, left, mid, right)
 
SENTINEL = 1000000001
n = int(eval(input()))
a = list(map(int, input().strip().split()))
count = 0
merge_sort(a, 0, len(a))
print((' '.join(map(str, a))))
print(count)
# Original solution
# -*- coding:utf-8 -*-
import sys


def merge(lst, left, mid, right):
    L = lst[left: mid]
    R = lst[mid: right]
    l_len = len(L)
    r_len = len(R)
    cnt = 0
    i = 0
    j = 0
    for k in range(left, right):
        cnt += 1
        if l_len > i or r_len > j:
            if l_len <= i:
                lst[k] = R[j]
                j += 1
            elif r_len <= j:
                lst[k] = L[i]
                i += 1
            elif L[i] <= R[j]:
                lst[k] = L[i]
                i += 1
            else:
                lst[k] = R[j]
                j += 1
    return cnt


def mergeSort(lst, left, right):
    if left + 1 < right:
        mid = (left + right) >> 1
        cnt = mergeSort(lst, left, mid)
        cnt += mergeSort(lst, mid, right)
        return merge(lst, left, mid, right) + cnt
    else:
        return 0


if __name__ == "__main__":
    lst = [val.split() for val in sys.stdin.read().splitlines()]
    data = [int(n) for n in lst[1]]
    cnt = mergeSort(data, 0, int(lst[0][0]))
    print((" ".join([str(n) for n in data])))
    print(cnt)

# Optimized solution
# -*- coding:utf-8 -*-
import sys


def merge(lst, left, mid, right):
    L = lst[left: mid]
    R = lst[mid: right]
    l_len = len(L)
    r_len = len(R)
    cnt = 0
    i = 0
    j = 0
    for k in range(left, right):
        cnt += 1
        if l_len <= i:
            lst[k] = R[j]
            j += 1
        elif r_len <= j:
            lst[k] = L[i]
            i += 1
        elif L[i] <= R[j]:
            lst[k] = L[i]
            i += 1
        else:
            lst[k] = R[j]
            j += 1
    return cnt


def mergeSort(lst, left, right):
    if left + 1 < right:
        mid = (left + right) >> 1
        cnt = mergeSort(lst, left, mid)
        cnt += mergeSort(lst, mid, right)
        return merge(lst, left, mid, right) + cnt
    else:
        return 0


if __name__ == "__main__":
    lst = [val.split() for val in sys.stdin.read().splitlines()]
    data = [int(n) for n in lst[1]]
    cnt = mergeSort(data, 0, int(lst[0][0]))
    print((" ".join([str(n) for n in data])))
    print(cnt)
# Original solution
n,m = list(map(int, input().split()))
ans = (n-2)*(m-2)
print((abs(ans)))

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

if n>m:
	w=n
	n=m
	m=w

if n==1:
	if m==1:
		print((1))
	else:print((m-2))
elif n==2:
	print((0))
else :
	print((n*m - (n-2)*2 - (m-2)*2 -4 ))
# Original solution
N, M = (int(i) for i in input().split())

tiles = [[True for i in range(M + 2)] for j in range(N + 2)]
for i in range(1, N + 1):
    for j in range(1, M + 1):
        tiles[i - 1][j - 1] = not (tiles[i - 1][j - 1])
        tiles[i - 1][j] = not (tiles[i - 1][j])
        tiles[i - 1][j + 1] = not (tiles[i - 1][j + 1])
        tiles[i][j - 1] = not (tiles[i][j - 1])
        tiles[i][j] = not (tiles[i][j])
        tiles[i][j + 1] = not (tiles[i][j + 1])
        tiles[i + 1][j - 1] = not (tiles[i + 1][j - 1])
        tiles[i + 1][j] = not (tiles[i + 1][j])
        tiles[i + 1][j + 1] = not (tiles[i + 1][j + 1])

count = 0

for i in range(1, N + 1):
    for j in range(1, M + 1):
        if not tiles[i][j]:
            count = count + 1
print(count)

# Optimized solution
N, M = (int(i) for i in input().split())

if N == 1 and M == 1:
    print((1))

elif N == 2 or M == 2:
    print((0))

elif N == 1 or M == 1:
    if N == 1:
        print((M - 2))
    else:
        print((N - 2))

else:
    print(((N - 2) * (M - 2)))
# Original solution
n, m = list(map(int, input().split()))
if min(n, m) == 1:
    if max(n, m) == 2:
        ans = 2
    elif max(n, m) == 1:
        ans = 1
    else:
        ans = max(n, m) - 2
elif min(n, m) == 2:
    ans = 0
else:
    ans = (n - 2) * (m - 2)
print(ans)


# Optimized solution
n, m = list(map(int, input().split()))
print((abs((n-2)*(m-2))))
# Original solution
n, m = list(map(int, input().split()))
l = [[-1 for j in range(m)] for i in range(n)]
for i in range(n):
    for j in range(m):
        l[i][j] *= -1
        if (j-1) >= 0: l[i][j-1] *= -1
        if (j+1) < m: l[i][j+1] *= -1
        if (i-1) >= 0:
            l[i-1][j] *= -1
            if (j-1) >= 0: l[i-1][j-1] *= -1
            if (j+1) < m: l[i-1][j+1] *= -1
        if (i+1) < n:
            l[i+1][j] *= -1
            if (j-1) >= 0: l[i+1][j-1] *= -1
            if (j+1) < m: l[i+1][j+1] *= -1
ans = 0
for i in range(n):
    ans += l[i].count(1)
print(ans)


# Optimized solution
n, m = list(map(int, input().split()))
print((abs((n-2)*(m-2))))
# Original solution
n, m = list(map(int, input().split()))
if n == 1 and m == 1:
	print((1))
elif n == 1:
	print((m-2))
elif m == 1:
	print((n-2))
else:
	print(((m-2)*(n-2)))

# Optimized solution
n, m = list(map(int, input().split()))
if n == 1 and m == 1:
	print((1))
	exit()
if n == 1 or m == 1:
	print((max(max(n,m)-2,0)))
elif n == 2 or m == 2:
	print((0))
else:
	print(((n-2)*(m-2)))
# Original solution
n,m = list(map(int,input().split()))
ans = 0
for i in range(1,n+1):
    if i == 1 or i == n:
        continue
    ans += abs(m-2)
if n == 1:
    if m == 1:
        ans = 1
    else:
        ans = m-2
print(ans)

# Optimized solution
n,m = list(map(int,input().split()))
if n == m == 1:
    ans = 1
elif n == 1 or m == 1:
    ans = n*m-2
elif n == 2 or m == 2:
    ans = 0
else:
    ans = (n-2)*(m-2)
print(ans)
# Original solution
def back(p, N, M):
    x, y = p
    if x == 0 and x == (N - 1) and y == 0 and y == (M - 1):
        return True

    if x == 0 and x == (N - 1) and (y == 0 or y == (M - 1)):
        return False

    if (x == 0 or x == (N - 1)) and y == 0 and y == (M - 1):
        return False

    if x == 0 and x == (N - 1):
        return True

    if y == 0 and y == (M - 1):
        return True

    if x == 0:
        return False

    if x == (N - 1):
        return False

    if y == 0:
        return False

    if y == (M - 1):
        return False

    return True



N, M = [int(i) for i in input().split()]

print((len([p for p in [[i, j] for i in range(N) for j in range(M)] if back(p, N, M)])))


# Optimized solution
def back(x, y, N, M):
    if x == 0 and x == (N - 1) and y == 0 and y == (M - 1):
        return True

    if x == 0 and x == (N - 1) and (y == 0 or y == (M - 1)):
        return False

    if (x == 0 or x == (N - 1)) and y == 0 and y == (M - 1):
        return False

    if x == 0 and x == (N - 1):
        return True

    if y == 0 and y == (M - 1):
        return True

    if x == 0:
        return False

    if x == (N - 1):
        return False

    if y == 0:
        return False

    if y == (M - 1):
        return False

    return True



N, M = [int(i) for i in input().split()]

print((len([None for i in range(N) for j in range(M) if back(i, j, N, M)])))
# Original solution
def back(x, y, N, M):
    if x == 0 and x == (N - 1) and y == 0 and y == (M - 1):
        return True

    if x == 0 and x == (N - 1) and (y == 0 or y == (M - 1)):
        return False

    if (x == 0 or x == (N - 1)) and y == 0 and y == (M - 1):
        return False

    if x == 0 and x == (N - 1):
        return True

    if y == 0 and y == (M - 1):
        return True

    if x == 0:
        return False

    if x == (N - 1):
        return False

    if y == 0:
        return False

    if y == (M - 1):
        return False

    return True



N, M = [int(i) for i in input().split()]

print((len([None for i in range(N) for j in range(M) if back(i, j, N, M)])))


# Optimized solution
N, M = [int(i) for i in input().split()]

if N == 1 and M == 1:
    print((1))
elif N == 1:
    print((M - 2))
elif M == 1:
    print((N - 2))
else:
    print((N * M - ((N - 2) * 2 + (M - 2) * 2) - 4))