Problem:


Score : 300 points

Problem Statement

There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region.
The front and back sides of these cards can be distinguished, and initially every card faces up.

We will perform the following operation once for each square contains a card:

For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square.

It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed.
Find the number of cards that face down after all the operations.

Constraints

1 \leq N,M \leq 10^9

All input values are integers.

Input

Input is given from Standard Input in the following format:

N M

Output

Print the number of cards that face down after all the operations.

Sample Input 1

2 2

Sample Output 1

0

We will flip every card in any of the four operations. Thus, after all the operations, all cards face up.

Sample Input 2

1 7

Sample Output 2

5

After all the operations, all cards except at both ends face down.

Sample Input 3

314 1592

Sample Output 3

496080



Sample input:
2 2


Sample output:
0

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

# 1の場合
# 2の場合
# 3以上の場合
#  最外でない場合は、9回処理されるので裏返る
#  最外でコーナーの場合は、4回処理されるのでそのまま
#  最外でコーナー以外の場合は、6回処理されるのでそのまま

if n == 2 or m == 2:
    print(0)
elif n == 1 or m == 1:
    w = m if n == 1 else n
    print(w - 2)
else:
    print((n - 2) * (m - 2))

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc090/tasks/arc091_a

import itertools
import collections
import bisect

def main():
    N, M = map(int, input().split())
    if N > 1 and M > 1:
        print((N-2)*(M-2))
    else:
        print(max(N, M) - 2)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    print(max(1, N-2) * max(1, M-2))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())

if n==1 or m==1:
    print(n+m-3)
else:
    print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
N,M=(int(i) for i in input().split())
if N==1 and M==1:
  print(1)
elif N==1 or M==1:
  print(2)
else:
  print((N-2)*(M-2))

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split())
    if N == 1 and M == 1:
        print(0)
    elif N == 1 or M == 1:
        print(N * M - 2)
    else:
        print((N - 2) * (M - 2))


main()

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split())
    if N == 1 or M == 1:
        print(N * M - 2)
    else:
        print((N - 2) * (M - 2))


main()

Submission status: Wrong Answer

Solution code:
import math
N,M=map(int,input().split())
n=math.fabs(N-2)
m=math.fabs(M-2)
ans=int(n*m)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N,M=map(int,input().split())
n=math.fabs(N)
m=math.fabs(M)
ans=int(n*m)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N,M=map(int,input().split())
ans=int(math.fabs((N-2)*(M-2)))
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N,M=map(int,input().split())
ans=math.fabs((N-2)*(M-2))
print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
if n==1 and m==7:
  exit()
if n==1:
  if m==1:
    print(1)
  else:
    print(m-2)
elif m==1:
  print(n-2)
else:
  print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
if n == 1 or m == 1:
    print(n * m - 2)
else:
    print(n * m - n * 2 - m * 2 + 4)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n,m=map(int, input().split())
if n==1:
    print(m-2)
elif m == 1:
    print(n-2)
else:
    print(n*m-(2*n+2*m-4))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
if (n == 1) or (m == 1):
    ans = max(n,m) -2
else:    
    ans = (n-2) * (m-2)
print(ans)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
if N>M:
    M,N=N,M
if N>1 and M>1:
    print((N-2)*(M-2))
elif N==1:
    print(M-2)
else:
    print(1)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())

if N == 1 or M == 1:
    if N == 1 and M == 1:
        res = 1
    else:
        res = max([N,M]) - 2
elif N == 2 or M == 2:
    if N == 3 or M == 3:
        res = 0
    else:
        res = N*M - 4
else:
    res = (M*N) - (N*2) - ((M-2)*2)

print(res)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())

if N == 1 or M == 1:
    if N == 1 and M == 1:
        res = 1
    else:
        res = max([N,M]) - 2
elif N == 2 or M == 2:
    res = N*M - 4
else:
    res = (M*N) - (N*2) - ((M-2)*2)

print(res)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())

if N == 1 or M == 1:
    res = max([N,M]) - 2
elif N == 2 or M == 2:
    res = N*M - 4
else:
    res = (M*N) - (N*2) - ((M-2)*2)

print(res)

Submission status: Wrong Answer

Solution code:
def solve(N, M):
    if N > 2 and M > 2:
        return (N - 2) * (M - 2)
    if N == 2 or M == 2:
        return 0
    if N == 1 or M == 1:
        return max(max(N, M) - 2, 0)

if __name__ == "__main__":
    N, M = tuple(map(int, input().split(" ")))
    print(solve(N, M))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
if(2<=N and 2<=M): 
    print((N-2)*(M-2))
elif(2<=N or 2<=M):
    print(max(N,M)-2)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())

if n==1 or m==1:
    ans = n*m-2
else:
    ans = (n-2)*(m-2)

print(ans)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
print(max(1,n-2)*max(1,m-2) if m-2>=1 or n-2>=1 else 0)

Submission status: Wrong Answer

Solution code:
n,k=map(int, input().split())
if n==2 or k==2:
    print(0)
elif n == 1 or k ==1:
    print(max(n,k)-2)
elif n == 1 and k == 1:print(1)
else:print((n-2)*(k-2))

Submission status: Wrong Answer

Solution code:
n,k=map(int, input().split())
if n==2 or k==2:
    print(0)
elif n == 1 or k ==1:
    print(max(n,k)-2)
else:print((n-2)*(k-2))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())

if N<M:
    N,M = M,N

ans = 0
if M==1:
    if M==1:
        ans = 1
    else:
        ans = M-2
elif M==2:
    ans = 0
else:
    ans = (N-2)*(M-2)

print(ans)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())

if(a == 1 or b == 1):
    print(max(a*b - 2, 0))
else:
    print((a-2)*(b-2))

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())

if(a == 1 or b == 1):
    print(a*b - 2)
else:
    print((a-2)*(b-2))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
print(max(N,M)-2 if N==1 or M==1 else N*M-2*N-2*M+4)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
if N >= 2 and M >= 2:
    print((N-2)*(M-2))
elif N >= 2:
    print(N-2)
elif M >= 2:
    print(M-2)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

if n == 1:
    print(n * (m - 2))
elif m == 1:
    print((n - 2) * m)
else:
    print((n - 2) * (m - 2))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())

if n == 1 or m == 1:
    if n == 1 :
        print(m-2)
    else:
        print(n-2)
else:
    print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
if n == 1 or m == 1:
    print(n+m-3)
elif n == 2 or m == 2:
    print(0)
else:
    print((n-2)*(m-2))

Submission status: Wrong Answer

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

print((N-2) * (M-2))

Submission status: Wrong Answer

Solution code:
n, m = map(int,input().split())
if n == 1:
    ans = m-2
elif m == 1:
    ans = n-2
else:
    ans = (n-2)*(m-2)
print(ans)

Submission status: Wrong Answer

Solution code:
# Flip, Flip, and Flip......
n, m = map(int, input().split())
if n == 1:
    print(m-2)
elif m == 1:
    print(n-1)
else:
    print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
if n == 1 or k == 1:
    print(n*k-2)
else:
    print(n*k-n*2-k*2+4)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
if n == 1:
    if m == 1:
        print(1)
    elif m == 2:
        print(0)
    elif m >= 3:
        print(m-2)
elif n == 2:
    print(0)
elif n >= 3:
    if m == 1:
        print(1)
    elif m == 2:
        print(0)
    elif m >= 3:
        print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())

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

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())

ans = 0
if N == 1:
    ans = M - 2
elif M == 1:
    ans = N - 2
else:
    ans = (N - 2) * ( M - 2)
print(ans)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())

ans = 0
if N == 1:
    for j in range(M):
        if j == 0 or j == M - 1:
            pass
        else:
            ans += 1
elif M == 1:
    for i in range(N):
        if i == 0 or i == N - 1:
            pass
        else:
            ans += 1
else:
    for i in range(N):
        for j in range(M):
            if i == 0 or j == 0 or i == N  - 1 or j == M - 1:
                pass
            else:
                ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
iN,iM = map(int,input().split())

if 2 < iN and 2 < iM:
    print((iN-2)*(iM-2))
elif iN == 2 or iM == 2:
    print(0)
else:
    if iN > 1:
        print(iN-2)
    else:
        print(iM-2)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
if a == 1:
  print(b-2)
elif b == 1:
  print(a-2)
else:
  print((a-2)*(b-2))

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
tmp = 0
if a > 1:
    tmp = 2*(max(b,0)-2)
print(a*b-2*max(a,0)-tmp)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
tmp = 0
if a > 1:
    tmp = 2*(max(b,0)-2)
print(a*b-2*a-tmp)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
tmp = 0
if a > 1:
    tmp = 2*(b-2)
print(a*b-2*a-tmp)

Submission status: Wrong Answer

Solution code:
(n, m)=map(int,input().split())
print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

if n >= 2 and m >= 2:
    print((n-2)*(m-2))
elif n == 2 or m == 2:
    print(0)
else:
    if n % 2 == 1 and m % 2 == 1:
        print(1)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

if n >= 2 and m >= 2:
    print((n-2)*(m-2))
elif n == 2 or m == 2:
    print(0)
else:
    print(1)

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
if n == 1:
  s = abs(m-2)
elif m == 1:
  s = abs(n-2)
else:
  s = 2*n+2*m-4
print(s)

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
if n == 1:
  s = abs(m-2)
elif m == 1:
  s = abs(n-2)
else:
  s = n*m-4
print(s)

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
if n == 1:
  s = abs(m-2)
elif m == 1:
  s = abs(n-2)
else:
  s = 4
print(s)

Submission status: Wrong Answer

Solution code:
N,M=map(int, input().split())
if N==1 or M==1:
	if N==1:
		print(M-2)
	else:
		print(N-2)
else:
	print((N-2)*(M-2))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

if n > 1:
    if m > 1:
        print((n - 2) * (m - 2))
    else:
        print(n - 2)
else:
    if m > 1:
        print(m - 2)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

if n == 1 and m == 1:
    print(1)
elif n == 1 or m == 1:
    print(n*m - 1)
else:
    print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
if n == 1:
    if m == 1:
        print(1)
    else:
        print(m - 2)
elif m == 1:
    print(m - 2)
else:
    print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
Keys=list(map(int,input().split()))
if Keys[0]>=2 and Keys[1]>=2:
    print(Keys[0]*Keys[1]-2*(Keys[0]+Keys[1]-2))
elif Keys[0]==1 and Keys[1]==1 :
    print(0)
else:
    print(max(Keys[0],Keys[1])-2)

Submission status: Wrong Answer

Solution code:
Keys=list(map(int,input().split()))
if Keys[0]>=2&Keys[1]>=2:
    print(Keys[0]*Keys[1]-2*(Keys[0]+Keys[1]-2))
elif Keys[0]==1 &Keys[1]==1 :
    print(0)
else:
    print(max(Keys[0],Keys[1])-2)

Submission status: Wrong Answer

Solution code:
a, b = map(int,input().split())
print((a-2)*(b-2))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
if n==1 or m==1:
    print(n*m-2)
elif n==2 or m==2:
    print(0)
else:
    print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
A = list(map(int, input().split()))

N = min(A)
M = max(A)

if(N > 2 and M > 2):
    print((N - 2) * (M - 2))
else:
    if(N == 2 or M <= 2):
        print(0)
    else:
        print(M-2)

Submission status: Wrong Answer

Solution code:
A = list(map(int, input().split()))

N = min(A)
M = max(A)

if(N>2 and M>2):
  print((N-2)*(M-2))
else:
  if(N==2 or M<=2):
    print(0)
  else:
    print(M-2)

Submission status: Wrong Answer

Solution code:
N, M = [int(c) for c in input().split()]

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

Submission status: Wrong Answer

Solution code:
N, M = [int(c) for c in input().split()]

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

Submission status: Wrong Answer

Solution code:
N, M = [int(c) for c in input().split()]

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

Submission status: Wrong Answer

Solution code:
N, M = list(map(int, input().split()))
if N == 1:
    if M == 1:
        print(0)
    else:
        print(M-2)
else:
    if M == 1:
        print(N-2)
    else:
        print((N-2) * (M-2))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if N > 1 and M > 1:
    print((N - 2) * (M - 2))
elif N == 1 or M == 1:
    print(N + M - 3)

Submission status: Wrong Answer

Solution code:
ary = list(map(int, input().split()))
ary = sorted(ary)

ans = -1
if ary[0] == 1:
    ans = max(0, ary[1] - 2)
elif ary[0] == 2:
    ans = 0
else:
    ans = (ary[0] - 2) * (ary[1] - 2)
print(ans)

Submission status: Wrong Answer

Solution code:
data = [int(n) for n in input().split()]
print(max((data[0]-2)*(data[1]-2), 0))

Submission status: Wrong Answer

Solution code:
data = [int(n) for n in input().split()]
print((data[0]-2)*(data[1]-2))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if N == 1 or M == 1:
    print(max(N * M - 2, 0))
else:
    print(N * M - (2 * N + 2 * M - 4))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
if N==1:
  print(M-2)
elif N==2:
  print(0)
else:
  print((M-2)*N)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
if N==1:
  print(M-2)
elif N==2:
  print(N*M-4)
else:
  print((M-2)*N)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
if N<=2:
  print(M-2)
else:
  print((M-2)*N)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
if N==1:
  print(M-2)
elif N==2:
  print(M+2)
else:
  print((M-2)*N)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
if b==1:
  print(b-2)
elif b==2:
  print(b+2)
else:
  print((b-2)*a)

Submission status: Wrong Answer

Solution code:
a, b = map(int,input().split())
c = [a,b]
c.sort()
if c[0] == 1:
    if c[1]==1:
        print(0)
    else:
        print(c[1]-2)
else:
    print((c[0]-2) * (c[1]-2))

Submission status: Wrong Answer

Solution code:
a, b = map(int,input().split())
c = [a,b]
c.sort()
if c[0] == 1:
    if c[1]==1:
        print(c[1]-2)
    else:
        print(c[1]-2)
else:
    print((c[0]-2) * (c[1]-2))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())

if N == 0 or M == 0 :
    print("0")
elif N == 1 and M == 1 :
    print("1")
elif N == 1 and M == 2 or N == 2 and M == 1 :
    print("0")
elif N == 1 :
    print(M - 2)
elif M == 1 :
    print(N - 2)
elif N <= 2 or M <= 2:
    print((N - 2) * 2 + (M - 2) * 2)
else :
    print((N - 2) * (M - 2))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
if n>2 and m>2:print((n-2)*(m-2))
elif min(n,m)==1:print(max(n,m)-2)
else: print(0)

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-

def main():
    n, m = map(int, input().split())

    if n >= 2 and m >= 2:
        cards = n * m - (n * 2 + (m - 2) * 2)
        print(cards)
    elif n == 1:
        print(m - 2)
    else:
        print(n - 2)
    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
if n > m: n,m = m,n
print(max(1, n - 2) * max(0, m - 2))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
def ura(N,M):
	if N == 1:
		return 1 if M == 1 else M-2
	elif N == 2:
		return 0
	else:
		return N*M-(2*M+2*N-4)
print(ura(N,M))

Submission status: Wrong Answer

Solution code:

def main():
    n,m = map(int,input().split())

    if n == 1 and m == 1:
        print(0)
    elif n == 1 and m > 1:
        print(m-2)
    elif n > 1 and m == 1:
        print(n-2)
    else:
        print((n-2) * (m-2))

if __name__ == "__main__":
        main()

Submission status: Wrong Answer

Solution code:
A,B=map(int,input().split())
if A==1 and B==1:
    print(1)
elif A==1:
    print(A-2)
elif B==1:
    print(B-2)
else:
    print((A-2)*(B-2))

Submission status: Wrong Answer

Solution code:
A,B=map(int,input().split())
if A==1 and B==1:
    print(1)
elif A==1:
    print(A-2)
elif B==1:
    print(A-2)
else:
    print((A-2)*(B-2))

Submission status: Wrong Answer

Solution code:
A,B=map(int,input().split())
print((A-2)*(B-2))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
A,B=map(int,input().split())

if A ==1 or B==1:
    print(A*B-2)

else:
    print(A*B-2*A-2*B+4)

Submission status: Wrong Answer

Solution code:

def main():
    nm = [int(i) for i in input().split()]

    nm.sort()
    # 自身と周辺のカードの枚数を数えて、偶数なら表、奇数なら裏
    if nm[0] == 1 and nm[1] == 1:
        # 1枚の時
        print(1)
    elif nm[0] == 1 and nm[1] == 2:
        # 2枚の時
        print(2)
    elif nm[0] == 1 and nm[1] > 2:
        # 1列の時、両端は自身と隣接2枚、途中は3枚なので、途中が裏
        print(nm[1] - 2)
    elif nm[0] == 2:
        # 2列の時、4隅が自身と隣接3枚、他は4枚
        print(4)
    elif nm[0] > 2 and nm[1] > 2:
        # 3行3列以上の時、4隅が4枚、端は6枚、真ん中は9枚
        print((nm[0]-2) * (nm[1]-2))
    else:
        raise ValueError


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N, M = [int(i) for i in input().split()]

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



main()

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
if N==1 and M==1:
  print(1)
elif N==1 and M!=1:
  print(M-2)
else:
  print((N-2)*(M-2))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
n = min(0, N-2)
m = min(0, M-2)

print(n*m)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())

if N==1 or M==1:
    if N==1 and M==1:
        print(0)
    else:
        if N < M:
            N, M = M, N
        print(N-2)

else:
    print((N*M) - N*2 - M*2 + 4)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())

if N==1 or M==1:
    if N < M:
        N, M = M, N
    print(N-2 if N-2<0 else 0)

else:
    print((N*M) - N*2 - M*2 + 4)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())

if N==1 or M==1:
    if N<M:
        N,M = M,N
    print(N-2)

else:
    print((N*M) - N*2 - M*2 + 4)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())

if N==1 or M==1:
    if N<M:
        N,M = M,N
    print(N-2)


print((N*M) - N*2 - M*2 + 4)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())

print((N*M) - N*2 - M*2 + 4)

Submission status: Wrong Answer

Solution code:
N, M = list(map(int,(input()).split()))
po = 0

if (N-1) * (M-1) == 0:
  po = max(N-2,M-2)
else:
  po = (N-2) * (M-2)

print(po)

Submission status: Wrong Answer

Solution code:
n, m = sorted(map(int, input().split()))

print(abs(n-2) * (m-2))

Submission status: Wrong Answer

Solution code:
m , n = map(int,input().split(" "))


if n == 1 and m == 1:
  print("1")
  exit()
elif n  == 2 and m == 2:
  print(0)
  exit()
elif n == 1 and m != 1:
  print (m - 2)
  exit()
else:
  print(((n-2)*(m-2)))
  exit()

Submission status: Wrong Answer

Solution code:
m , n = map(int,input().split(" "))


if n == 1 and m == 1:
  print("1")
  exit()
elif n == 1 and m != 1:
  print (m - 2)
  exit()
else:
  print(((n-2)*(m-2)))
  exit()

Submission status: Wrong Answer

Solution code:
m , n = map(int,input().split(" "))

print(((n-2)*(m-2)))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())


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

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

else:
    print((N-2)*(M-2))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
s, l = min(N, M), max(N, M)

if s == 1:
  print(max(l - 2, 0))
elif s == 2:
  print(0)
else:
  print(s * l - (s * 2 + l * 2 - 4))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
s, l = min(N, M), max(N, M)

if s == 1:
  print(l - 2)
elif s == 2:
  print(0)
else:
  print(s * l - (s * 2 + l * 2 - 4))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
s, l = min(N, M), max(N, M)

if s == 1:
  print(l - 1)
elif s == 2:
  print(l)
else:
  print(s * l - (s * 2 + l * 2 - 4))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())

N,M = min(N,M),max(N,M)
Ans = 0
if N==1 and M==1:
    Ans = 0
elif N==1:
    Ans = M-2
elif N==2:
    Ans = 0
else:
    Ans = (N-2)*(M-2)

print(Ans)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())

N,M = min(N,M),max(N,M)
Ans = 0
if N==1 and M==1:
    Ans = 0
elif N==1:
    Ans = M-2
elif N%2==0 or M%2==0:
    Ans = 0
else:
    Ans = (N-2)*(M-2)

print(Ans)

Submission status: Wrong Answer

Solution code:
# input
N, M = map(int, input().split())

if N >= 2 and M >= 2:
    print((N - 2) * (M - 2))
else:
    print(max(0, N - 2, M - 2))

Submission status: Wrong Answer

Solution code:
n,m = input().split()
N=int(n)
M=int(m)
if(N==1 and M==1):
	print(0)
elif(N == 1):
	print(M-2)
elif(M == 1):
	print(N-2)
else:
	print((N-2)*(M-2))

Submission status: Wrong Answer

Solution code:
n,m = input().split()
N=int(n)
M=int(m)
if(N==1 and M==1):
	print(0)
elif(N == 1):
	print(M-2)
elif(M == 1):
	print(N-2)
elif(N>=2 and M>=2):
	print((N-2)*(M-2))

Submission status: Wrong Answer

Solution code:
n,m = input().split()
N=int(n)
M=int(m)
if(N == 1):
	print(M-2)
elif(M == 1):
	print(N-2)
elif(N==1 and M==1):
	print(0)
elif(N>=2 and M>=2):
	print((N-2)*(M-2))

Submission status: Wrong Answer

Solution code:
n,m = input().split()
N=int(n)
M=int(m)
if(N == 1):
	print(M-2)
elif(M == 1):
	print(N-2)
elif(N>=2 and M>=2):
	print((N-2)*(M-2))

Submission status: Wrong Answer

Solution code:
n,m = input().split()
N=int(n)
M=int(m)
if(N == 1):
	print(M-2)
elif(M == 1):
	print(N-2)
elif(N>=3 and M>=3):
	print((N-2)*(M-2))
else:
	print(0)

Submission status: Wrong Answer

Solution code:
n,m = input().split()
N=int(n)
M=int(m)
if(N == 1):
	print(M-2)
elif(M == 1):
	print(N-2)
elif(N>=3 and M>=3):
	print((N-2)*(M-2)+4)
else:
	print(0)

Submission status: Wrong Answer

Solution code:
#!C:\Users\daichi\Anaconda3/python.exe
# -*- coding: utf-8 -*-

C = input().split()
N = int(C[0])
M = int(C[1])

if(N % 2 == 0): 
    N1=N
else:
    if(N-2<1):
        N1=1
    else:
        N1=N-2  
 
if(M % 2 == 0):
    M1=M
else:
    if(M-2<1):
        M1=1
    else:
        M1=M-2 
    
print(N1*M1)

Submission status: Wrong Answer

Solution code:
def m():
    n, m = map(int, input().split())
    if n == 1:
        return m-2
    if m == 1:
        return n-2
    if n == 2 or m == 2:
        return 0
    return (m-2) * (n-2)

print(m())

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
print(abs(N - 2) * (M - 2))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

if n == 1:
    ans = max(0, m - 2)
elif m == 1:
    ans = max(0, n - 2)
else:
    ans = (n - 2) * (m - 2)
print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
if(n == 1 or m == 1):
    print("%d" %(n + m - 3))
else:
    print("%d" % (n*m - ((n-1)*2 + (m-1)*2)))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())

if N>M:
    tmp=N
    N=M
    M=tmp

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

Submission status: Wrong Answer

Solution code:
N, M = input().split()
N = int(N)
M = int(M)

if N==1 or M==1:
    print(max(N,M)-2)
else:
    print((M-2)*(N-2))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
if N>M:
    N,M=M,N
if N==1:
    print(max(0,M-2))
else:
    print((N-2)*(M-2))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if N == 1 and M == 1:
    print(1)
elif N == 1 and M > 1:
    print(M-2)
elif M == 1 and N > 1:
    print(N-2)
elif N > 1 and M > 2:
    print((N-2)*(M-2))

Submission status: Wrong Answer

Solution code:
a, b = list(map(int, input().split()))
if(a>=2 and b>=2):
    print((a-2)*(b-2))
elif a==1:
    print(b-2)
else:
    print(a-2)

Submission status: Wrong Answer

Solution code:
def main():
    N, M = [int(i) for i in input().split()]
    if(N == 1 and M == 1):
        print(0)
    elif(N == 1):
        print(M - 2)
    elif(M == 1):
        print(N - 2)
    else:
        print(N*M - (N*2 + M*2 - 4 ))
    
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N, M = [int(i) for i in input().split()]
    if(N == 1):
        print(M - 2)
    elif(M == 1):
        print(N - 2)
    else:
        print(N*M - (N*2 + M*2 - 4 ))
    
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
n, m = map(int,input().split())

if n>1 and m>1:
    print((n-2)*(m-2))
elif n ==1 and m >1:
    print(m-2)
elif n >1 and m==1:
    print(m-2)
else:
    print(1)

Submission status: Wrong Answer

Solution code:
n, m = map(int,input().split())

print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n, m = list(map(int, input().split()))

if n == 1 and m == 1:
    print(1)
elif n == 1 and m > 1:
    print(m - 2)
else:
    print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n, m = list(map(int, input().split()))

if n == 1 and m == 1:
    print(1)
elif n == 1 and m == 2:
    print(0)
elif n == 1 and m > 2:
    print(m - 2)
else:
    print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
num = 0
nm1 = [int(x) for x in input().split()]

if nm1[0] == 1:
    print(nm1[1]-2)
elif nm1[1] == 1:
    print(nm1[0]-2)
else:
    print((nm1[0]-2)*(nm1[1]-2))

Submission status: Wrong Answer

Solution code:

nm1 = [int(x) for x in input().split()]

if nm1[0] == 1:
    print(nm1[1]-2)
elif nm1[1] == 1:
    print(nm1[0]-2)
else:
    print((nm1[0]-2)*(nm1[1]-2))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
print(abs(N-2)*(M-2))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())

small=min(N,M)
big  =max(N,M)
if small==1:
    if big==1:
        print (1)
    if big==2:
        print (0)
    else:
        print (big-2)

elif small==2:
    print (0)
    
else:
    print ((small-2)*(big-2))

Submission status: Wrong Answer

Solution code:
n,m=list(map(int,input().split()))
print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

if n == 1 or m == 1:
    print(n*m-2)

elif n == 1 and m == 1:
    print(1)

else:
    print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

if n == 1 or m == 1:
    print(n*m-2)

else:
    print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

if n == 1:
    print(m - 2)
elif m == 1:
    print(n - 2)
elif n == 2 or m == 2:
    print(0)
else:
    print((n - 2) * (m - 2))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
if 2<=n and 2<=m:
    print((m-2)*(n-2))
elif m==1 and 2<=n:
    print(n-2)
elif n==1 and 2<=m:
    print(m-2)

Submission status: Wrong Answer

Solution code:
N, M = input().split()

N = int(N)
M = int(M)

if N == 1 and M == 1:
    num = 1
elif N == 1:
    num = M - 2
else:
    num = (N - 2) * (M - 2)

print(num)

Submission status: Wrong Answer

Solution code:
N, M = input().split()

N = int(N)
M = int(M)

num = (N - 2) * (M - 2)
print(num)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
if n == 1 and m == 1:
    print("1")
elif n == 1:
    print(m-2)
else:
    print((n-2)*(m-2))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
if n == 1 and m == 1:
    print('1')
elif n == 1 and m != 1:
    print(m - 2)
else:
    print((n - 2) * (m - 2))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

x = n - 2
if x < 0:
    x = 0

y = m - 2
if y < 0:
    y = 0

if n == 1 and m > 1:
    print(y)
elif n > 1 and m == 1:
    print(x)
else:
    print(x * y)

Submission status: Wrong Answer

Solution code:
N,M = list(map(int,input().split()))
ans = (N-2)*(M-2)
print(ans)

Submission status: Wrong Answer

Solution code:
S = input().split(" ")
A = int(S[0]) * int(S[1]) - int(S[0])*2 - (int(S[1])*2-4)
if int(S[0]) == 1 or int(S[1]) == 1 and int(S[0]) * int(S[1]) != 1:
    A = int(S[0]) * int(S[1]) - 2
A = max(0,A)
print(A)

Submission status: Wrong Answer

Solution code:
# -- coding: utf-8 --
N, M = map(int, input().split(' '))
count = 0
if N == 1 or M == 1:
    if M == 1 or N == 1:
        count = 1
    else:
        count = M - 2
count = (N - 2) * (M - 2)
print(count)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if n == 1 or m == 1:
    if n == m:
        a = 1
    else:
        a = n + m - 3
elif n == 2 or m == n:
    a = 0
else:
    a = (n - 2) * (m - 2)

print(a)

Submission status: Wrong Answer

Solution code:
N, M = (int(i) for i in input().split())

if N == 1 and M == 1:
    print(0)
    
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))